Laravel Octane worker count #52133
Replies: 1 comment
-
Every worker can only handle 1 request at a time. So if the worker count is equal to the CPU count it could happen that there are not enough workers to fully utilize your CPU cores if many workers are simultaneously busy fetching from cache/database/filesystem (which will make them block). So a good default setting would be to use around 2x times as many workers as you have CPU cores to ensure that the CPUs are being used to a fuller extent. Frankenphp will actually create 2x the amount of workers, which is probably a better default than Swoole which will does 1x CPU cores. The Swoole default probably comes from it most often being used in its async mode, where 1x the number of CPU cores is enough to fully utilize all CPU cores. Laravel Octane does not run asynchronous though so it benefits from a higher amount of workers. Why not use many more workers then? The tradeoff for having more workers is that you also consume more memory. The bottleneck will more often be your CPU though. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi, Laravel Octane states that it'll create a worker for each CPU core. I'm wondering here, how many requests then can an actual CPU core handle or is it better to actually just set the number of workers significantly higher than what Octane thinks it should start?
Beta Was this translation helpful? Give feedback.
All reactions