Appwrite SDK‑Server Concurrency Limit: Configurable via Environment Variable?
0 reputation · 16 Jan 2022, 16:11 UTC
0 reputation · 16 Jan 2022, 16:11 UTC
The goal is to ascertain whether Appwrite exposes a maximum concurrent request limit through an environment variable such as APPWRITE_MAX_CONCURRENCY, allowing operators to tune the point at latency‑spike onset under concurrent SDK‑server traffic.
Observed latency increases only when many concurrent requests are made, suggesting a possible ceiling on simultaneous handling. It remains unclear whether this ceiling is hard‑coded in the server implementation or can be adjusted via configuration, leaving operators without a predictable knob to mitigate the behavior.
Is there an environment variable like APPWRITE_MAX_CONCURRENCY that controls the maximum concurrent request limit in the Appwrite server? If not, what is the hard‑coded limit and where is it defined in the source? How can the effective limit be verified in a running Appwrite instance?
34775 reputation · 16 Jan 2022, 19:41 UTC
Appwrite does not expose an environment variable named APPWRITE_MAX_CONCURRENCY. The server runs on PHP with Swoole (via the Utopia framework), not Go. Concurrent request capacity is determined by the number of Swoole worker processes, which is derived from CPU cores and a per-core multiplier.
_APP_WORKER_PER_CORE (default: 4) – multiplier applied to the number of CPU cores to set the target worker count._APP_MAX_WORKERS (default: 0, meaning unlimited) – hard ceiling on worker processes._APP_MIN_WORKERS (default: 0) – minimum workers to keep alive.The effective worker count at startup is min(max(cpu_cores * _APP_WORKER_PER_CORE, _APP_MIN_WORKERS), _APP_MAX_WORKERS). Each worker can handle many concurrent connections asynchronously via Swoole's event loop, so the practical concurrency limit is workers × connections-per-worker, bounded by OS file-descriptor limits and memory.
In the Appwrite repository (appwrite/appwrite), the Swoole HTTP server is bootstrapped in src/Appwrite/App.php (method runHttp). The worker count is calculated in src/Appwrite/Config.php or the Utopia framework's Swoole wrapper. Search for _APP_WORKER_PER_CORE in the codebase to trace the exact logic for your version.
docker exec env | grep -E '_APP_WORKER|_APP_MAX_WORKERS|_APP_MIN_WORKERS'
docker exec ps aux | grep 'swoole' | grep -v grep
Count the worker lines (exclude master/manager processes). This reflects the active concurrency slots.
/v1/health or a Swoole status page. If enabled, the response includes worker_num, idle_workers, and connection counts.
wrk -t4 -c200 -d30s http://host/v1/health
Watch for the latency inflection point; it typically aligns with worker_num × Swoole's max_connections_per_worker (default ~10,000) or the OS ulimit -n.
_APP_WORKER_PER_CORE (e.g., to 8) or set _APP_MAX_WORKERS explicitly.docker run --ulimit nofile=65536:65536 ….Please share your Appwrite version (e.g., 1.5.2, 1.6.0) and whether you run the official Docker image or a custom build. The exact variable names and source locations shifted slightly between 1.4.x and 1.5.x, so the version determines which config keys are authoritative.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.