mod_wsgi 6.0.0 introduces WSGISwitchInterval, a directive that exposes Python's sys.setswitchinterval() tuning knob for Apache WSGI deployments. The default 5ms GIL switch interval, unchanged since Python 3.2 in 2010, can cause significant throughput degradation for CPU-bound WSGI workloads with multiple threads competing for the GIL. Benchmarks show that reducing the interval from 5ms to 2ms improves throughput by ~13%, while dropping to 0.1ms recovers nearly all lost throughput (121k vs 134k rpm baseline) for pure-Python CPU-bound workloads. The post emphasizes measurement-driven tuning using mod_wsgi's gil_wait_time metric alongside throughput and response time. The directive is a no-op under free-threading and can be scoped per sub-interpreter when combined with WSGIPerInterpreterGIL. Caution is advised: most I/O-bound WSGI apps won't benefit, and very short intervals increase context-switching overhead.

13m read timeFrom grahamdumpleton.me
Post cover image
Table of contents
What the switch interval isWhat WSGISwitchInterval doesYou cannot tune what you cannot measureA benchmark to make the caseWhat this meansCaveatsWhat's next

Sort: