mirror of
https://github.com/frappe/gunicorn.git
synced 2026-07-01 10:11:30 +08:00
Replace lock-based request serialization with queue-based approach: - Each worker now has a dedicated asyncio.Queue and consumer task - route_request() submits (request, future) to queue and awaits future - Consumer task processes requests sequentially per worker - No lock contention - pure async queue operations Benefits: - Clearer separation of concerns - Better visibility into request backlog (queue.qsize()) - Eliminates lock contention under high concurrency Changes: - worker_locks dict replaced with worker_queues and worker_consumers - Added _start_worker_consumer() to create queue and consumer per worker - Added _execute_on_worker() for actual worker communication - Updated _cleanup_worker() to cancel consumer tasks - Updated stop() to cancel all consumers before shutdown Benchmark results (4 workers, isolated): - throughput_10ms: 333 req/s, 0 failures - overload_10ms (200 clients): 334 req/s, 0 failures - All tests pass with perfect round-robin distribution