I kept adding Horizon workers to a 2 GB Laravel Cloud box until memory was at about 90%. I got to 27.
Then I made the workers share their compiled code and did it again. Same box, same app, same 600 jobs a minute. This time it held 210.
This was a memory test, not a speed test. At that job rate CPU was never the limit. Memory was. Running the same 210 workers stock took a 16 GB box.
I started looking into this because a couple of my servers were sitting in swap, and Horizon was a big part of what filled them.
Every worker boots your whole app
Each queue:work is its own PHP process. So is every Horizon worker, and (this one surprised me) every Horizon supervisor. Each of them boots Laravel and compiles the code it touches into its own private memory.
The Supervisor example in the Laravel docs uses numprocs=8 . If you copied it, you have eight processes, each holding its own copy of the same compiled app.
In my Docker benchmark, a stock Horizon worker took about 63 MB. Supervisors are the funny part.β¦