From ab31a33f07a75ce12a97690dcc388241ccb2fb85 Mon Sep 17 00:00:00 2001 From: Kenneth Reitz Date: Fri, 10 Apr 2026 10:46:37 -0400 Subject: [PATCH] Add runtime-threads to granian config (2 workers x 2 threads) Increases concurrency on 1 dedicated CPU by using multi-threaded Rust runtime per worker. Co-Authored-By: Claude Opus 4.6 (1M context) --- Dockerfile | 2 +- fly.toml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 5d6ec8f..d88e2af 100644 --- a/Dockerfile +++ b/Dockerfile @@ -51,4 +51,4 @@ RUN python3 -c "from kjvstudy_org.utils.search_index import init_search_index; i # Run with granian for production: # Rust-based ASGI server — static files served directly from Rust layer -CMD ["sh", "-c", "uv run granian kjvstudy_org.server:app --interface asgi --host ${HOST:-0.0.0.0} --port ${PORT:-8000} --workers ${WORKERS:-2} --respawn-failed-workers --access-log --static-path-route /static --static-path-mount /app/kjvstudy_org/static --static-path-expires 86400"] +CMD ["sh", "-c", "uv run granian kjvstudy_org.server:app --interface asgi --host ${HOST:-0.0.0.0} --port ${PORT:-8000} --workers ${WORKERS:-2} --runtime-threads ${RUNTIME_THREADS:-2} --respawn-failed-workers --access-log --static-path-route /static --static-path-mount /app/kjvstudy_org/static --static-path-expires 86400"] diff --git a/fly.toml b/fly.toml index 7dd5e6f..c369174 100644 --- a/fly.toml +++ b/fly.toml @@ -46,5 +46,6 @@ PYTHONDONTWRITEBYTECODE = "1" # Lazy-load interlinear data to reduce memory usage PRELOAD_INTERLINEAR = "false" -# Granian workers (1 dedicated CPU = 2 workers) +# Granian: 2 workers x 2 runtime threads on 1 dedicated CPU WORKERS = "2" +RUNTIME_THREADS = "2"