Buckets:

download
raw
3.03 kB
{
"role_mappings": [
{
"role": "Entity",
"status": "present",
"symbol": "run_single",
"file": "backend/mlx_manager/mlx_server/benchmark/runner.py",
"lines": "102",
"notes": "In-repo benchmark CLI client (BenchmarkRunner.run_single, driven by mlx_server/benchmark/cli.py) POSTs /v1/chat/completions to the MLX server (runner.py:139/158), whose requests pass the RateLimitMiddleware Enforcer. Caveat: it is a load/benchmark tool; other callers (frontend, OpenAI clients) are outside the repo."
},
{
"role": "Enforcer",
"status": "present",
"symbol": "dispatch",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"lines": "110",
"notes": "RateLimitMiddleware.dispatch intercepts every request, derives the client IP (_get_client_ip, rate_limit.py:86), calls bucket.consume() (rate_limit.py:121) and returns 429 with Retry-After or forwards via call_next. Registered by app_instance.add_middleware in create_app (mlx_server/main.py:248), only when rate_limit_rpm > 0 (default 0 = disabled; opt-in via config)."
},
{
"role": "Limiter",
"status": "present",
"symbol": "consume",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"lines": "39",
"notes": "Called from dispatch (rate_limit.py:121). TokenBucket.consume refills tokens by elapsed time * rate (capped at capacity) and returns True/False to allow or block; it also updates the bucket state (history update step)."
},
{
"role": "HistoryProvider",
"status": "present",
"symbol": "_get_bucket",
"file": "backend/mlx_manager/mlx_server/middleware/rate_limit.py",
"lines": "93",
"notes": "Called from dispatch (rate_limit.py:119); returns the per-IP TokenBucket from the in-memory dict self._buckets (rate_limit.py:82), whose tokens/last_refill encode the request history and are updated in consume. Stale buckets pruned by _maybe_cleanup (rate_limit.py:99)."
},
{
"role": "PolicyProvider",
"status": "present",
"symbol": "rate_limit_rpm",
"file": "backend/mlx_manager/mlx_server/config.py",
"lines": "169",
"notes": "Policy is the settings field rate_limit_rpm (requests per minute per IP, default 0), passed to RateLimitMiddleware(rpm=...) at mlx_server/main.py:248 and turned into bucket rate/capacity in __init__ (rate_limit.py:78) and _get_bucket (rate_limit.py:96). No dedicated get_policy method exists, so the config field is cited."
},
{
"role": "System",
"status": "present",
"symbol": "create_chat_completion",
"file": "backend/mlx_manager/mlx_server/api/v1/chat.py",
"lines": "80",
"notes": "Reached via call_next in dispatch (rate_limit.py:139) through v1_router (api/v1/__init__.py:16, included at mlx_server/main.py:254); the /v1/chat/completions handler performs inference. Other v1 routes (completions, embeddings, messages, ...) are protected equally."
}
]
}

Xet Storage Details

Size:
3.03 kB
·
Xet hash:
47c52cdff0112ce5922483b99c1c05fcd14521813e71aebb74b82ca4c0062cd8

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.