Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/fault-tolerance/request-rejection.md
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ Content-Type: application/json
}
```

#### Configuring the rejection status code

The status code returned for overload rejections is configurable via the
`DYN_HTTP_OVERLOAD_STATUS_CODE` environment variable on the frontend. It
defaults to `529` ("Site is overloaded"). Operators whose proxies or clients
only understand `503` Service Unavailable retry semantics can set
`DYN_HTTP_OVERLOAD_STATUS_CODE=503`. Any valid HTTP status code is accepted; an
unparseable or out-of-range value falls back to `529`.

### Client Retry Strategy

Clients should implement exponential backoff when receiving 529 responses:
Expand Down
14 changes: 13 additions & 1 deletion lib/llm/src/http/service/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,22 @@
// SPDX-License-Identifier: Apache-2.0

use axum::http::StatusCode;
use dynamo_runtime::config::environment_names::llm as env_llm;
use thiserror::Error;

/// HTTP status code returned for overload / admission-control rejections.
///
/// Defaults to 529 ("Site is overloaded"). Operators can override it via the
/// `DYN_HTTP_OVERLOAD_STATUS_CODE` env var (e.g. `503` for Service Unavailable
/// retry semantics). An unset, unparseable, or out-of-range value falls back to
/// the 529 default.
pub(crate) fn overload_status_code() -> StatusCode {
StatusCode::from_u16(529).expect("529 is a valid HTTP status code")
let default = StatusCode::from_u16(529).expect("529 is a valid HTTP status code");
std::env::var(env_llm::DYN_HTTP_OVERLOAD_STATUS_CODE)
.ok()
.and_then(|s| s.trim().parse::<u16>().ok())
.and_then(|n| StatusCode::from_u16(n).ok())
.unwrap_or(default)
}

/// Implementation of the Completion Engines served by the HTTP service should
Expand Down
7 changes: 7 additions & 0 deletions lib/runtime/src/config/environment_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,13 @@ pub mod llm {
pub const DYN_HTTP_GRACEFUL_SHUTDOWN_TIMEOUT_SECS: &str =
"DYN_HTTP_GRACEFUL_SHUTDOWN_TIMEOUT_SECS";

/// HTTP status code returned when the frontend rejects a request because
/// all workers are overloaded. Defaults to 529 ("Site is overloaded"); set
/// to 503 for Service Unavailable retry semantics. Any valid HTTP status
/// code (100–999) is accepted; an unparseable or out-of-range value falls
/// back to 529.
pub const DYN_HTTP_OVERLOAD_STATUS_CODE: &str = "DYN_HTTP_OVERLOAD_STATUS_CODE";
Comment thread
nnshah1 marked this conversation as resolved.
Resolved

/// Enable LoRA adapter support (set to "true" to enable)
pub const DYN_LORA_ENABLED: &str = "DYN_LORA_ENABLED";

Expand Down
Loading