Process Management
Learning Focus
By the end of this lesson you will understand how OpenLiteSpeed spawns and manages PHP workers, what limits to configure, and how to right-size worker pools.
How PHP Worker Management Works
OpenLiteSpeed manages lsphp workers through the external application definition. It controls how many workers to spawn, when to create new ones, and when to recycle idle workers.
Key Settings
| Setting | What It Controls | Recommended Range |
|---|---|---|
| Max Connections | Maximum concurrent PHP requests | 10-50 depending on RAM |
| Initial Request Timeout | Time to wait for first response | 60s |
| Retry Timeout | Delay before retrying a failed connection | 0 |
| Persistent Connection | Keep lsphp connections alive | Yes |
| Response Buffering | Buffer PHP output | Yes |
Sizing PHP Workers
The formula: Workers × memory_limit ≤ Available RAM
| Server RAM | PHP memory_limit | Max Workers |
|---|---|---|
| 1 GB | 128 MB | 6-8 |
| 2 GB | 128 MB | 12-15 |
| 4 GB | 256 MB | 12-16 |
| 8 GB | 256 MB | 25-30 |
# Check current PHP worker count
ps aux | grep lsphp | grep -v grep | wc -l
# Check memory per worker
ps aux | grep lsphp | awk '{print $6/1024 " MB"}'
warning
Too many PHP workers cause swap pressure and worse performance. Too few workers increase request queueing. Always size from actual memory usage.
Key Takeaways
- PHP worker count should be based on available RAM and memory_limit, not guesswork.
- Monitor worker counts and memory usage under real traffic.
- Use persistent connections to reduce worker creation overhead.
What's Next
- Continue to Performance Benefits for more on LSAPI advantages.