About 100 people work in one of my applications. It started as a threading application, but performance issues (latency) were affected. So I converted these workers to multiprocessing.Process es. The comparative example below shows that load reduction was achieved by increasing memory usage (factor 6).
So, where exactly does memory use come from if Linux uses a cow and workers don't share any data?
How to reduce the amount of memory? (Alternative question: how to reduce threading load?)
Benchmarks on Linux 2.6.26, 4 CPU 2G RAM: (Please note that CPU usage is% of a single processor, so full load is 400%. The numbers are from viewing Munin diagrams.)
| threading | multiprocessing ------------------+-----------+---------------- memory usage | ~0.25GB | ~1.5GB context switches | ~1.5e4/s | ~5e2/s system cpu usage | ~30% | ~3% total cpu usage | ~100% | ~50% load avg | ~1.5 | ~0.7
Background: The application processes events from the network and stores some of them in the MySQL database.
source share