Build a worker
Create and deploy a load balancing worker.
vLLM load balancer
Deploy vLLM with load balancing.
Load balancing vs. queue-based endpoints
Queue-based endpoints
With queue-based endpoints, are placed in a queue and processed in order. They use the standard handler pattern (def handler(job)) and are accessed through fixed endpoints like /run and /runsync.
These endpoints are better for tasks that can be processed asynchronously and guarantee request processing, similar to how TCP guarantees packet delivery in networking.
Load balancing endpoints (new)
Load balancing endpoints send requests directly to workers without queuing. You can use any HTTP framework such as FastAPI or Flask, and define custom URL paths and API contracts to suit your specific needs. These endpoints are ideal for real-time applications and streaming, but provide no queuing mechanism for request backlog, similar to UDP’s behavior in networking.Endpoint type comparison table
Worker comparison
Queue-based worker (traditional):https://ENDPOINT_ID.api.runpod.ai/ping and https://ENDPOINT_ID.api.runpod.ai/generate
Health checks
Each worker exposes a health check endpoint on thePORT_HEALTH port, and the load balancer polls it periodically to decide whether the worker is healthy enough to receive traffic. By default the load balancer polls /ping, but you can point it at any path by setting the HEALTH_CHECK_PATH environment variable. This is useful when you deploy a public image whose server already exposes a health check at a different path, such as a llama.cpp image that serves /health, so you don’t need to build a custom image just to satisfy the health check.
You can also set the health check path directly in the Runpod console when creating a new endpoint. The Health check endpoint field appears on the Configure image step. Leave it empty to use the default
/ping.
Unhealthy workers are automatically removed from the routing pool.
When calculating endpoint metrics, Runpod calculates the cold start time for load balancing workers by measuring the time it takes between the health check endpoint first returning
204 until it first returns 200.Environment variables
If using a custom port, add it to your endpoint’s environment variables and expose it in container configuration (under Expose HTTP Ports (Max 10)).
Timeouts and limits
For payloads larger than 30 MB, use network volumes or implement chunking.
Handling cold starts
When workers are initializing, you may get “no workers available” errors. Implement retry logic to handle this:When to use load balancing endpoints
Use load balancing endpoints when you need:- Direct access to your model’s HTTP server.
- Internal batching systems (like vLLM).
- Non-JSON payloads.
- Multiple endpoints within a single worker.
- Lower latency for real-time applications.