Deploy custom direct-access REST APIs with load balancing Serverless endpoints.
/run
or /runsync
endpoints. Instead, you can create custom REST endpoints that are accessible via a unique URL:
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.
Aspect | Load Balancing | Queue-Based |
---|---|---|
Request flow | Direct to worker HTTP server | Through queueing system |
Implementation | Custom HTTP server | Handler function |
Protocol flexibility | Supports any HTTP capability | JSON input/output only |
Backpressure handling | Request drop when overloaded | Queue buffering |
Latency | Lower (single-hop) | Higher (queue+worker) |
Error recovery | No built-in retry mechanism | Automatic retries |
/run
and /runsync
./ping
endpoint on the port specified by the PORT_HEALTH
environment variable. The load balancer periodically sends requests to this endpoint. Workers respond with appropriate HTTP status codes:
200
: healthy204
: initializing/ping
first returning 204
until it first returns 200
.PORT
: The port for the main application server (default: 80
).PORT_HEALTH
: The port for the health check endpoint (default: PORT
).MODEL_NAME
) for application-specific configuration.PORT
or PORT_HEALTH
during deployment, environment variables will automatically be set to 80
for both, and port 80 will be automatically exposed in the container configuration.
If you’re using a custom port, make sure to add it to your endpoint’s environment variables, and expose it in the container configuration of your endpoint settings (under Expose HTTP Ports (Max 10)).
MAX_WORKERS
), the system returns a 400
error. To implement retries, you should account for this response code in your client-side application.524
error. For tasks that consistently take longer than 5.5 minutes to process, load balancing endpoints may not be suitable.502
error. This is a known issue and a fix is in progress.https://ENDPOINT_ID.api.runpod.ai/PATH
, the system: