The Manager serves as the central hub in Backend.AI's architecture. It receives requests from clients and orchestrates operations across Agents, Storage-Proxy, and App-Proxy services.
Apply HTTP middleware to the aiohttp application. The middleware:
- Extracts
X-Backend-Request-IDheader if present - Generates new request ID if not present
- Binds request ID to context
- Adds
X-Backend-Request-IDto response headers
Apply context binding decorator to background tasks that don't originate from HTTP requests. The decorator auto-generates request ID and binds it to the async context.
Restore request ID from event metadata for causality tracking.
Manager communicates with Agents via Callosum RPC. Include request ID in the request body:
request_body = {
"headers": {"request_id": get_current_request_id()}, # from context
"args": args,
"kwargs": kwargs,
}Legacy Agents without headers support will ignore the headers field.
Include X-Backend-Request-ID header in all outbound HTTP requests.
- EventProducer: Include request_id in event metadata
- EventDispatcher: Restore request_id from metadata when handling events
Client Manager Service
│ │ (Agent/Storage/App-Proxy)
│ HTTP Request │ │
├────────────────────────▶│ │
│ │ │
│ middleware generates request_id │
│ │ │
│ │ RPC or HTTP call │
│ │ (with request_id) │
│ ├────────────────────────▶│
│ │ │
│ │◀────────────────────────┤
│ │ │
│ X-Backend-Request-ID │ │
│◀────────────────────────┤ │
- HTTP middleware applied to main app and sub-apps
- Context binding decorator on background tasks
- Agent RPC calls include headers
- Storage-Proxy/App-Proxy HTTP calls include header
- Event system propagates request_id