I am looking into load balancing and some other optimizations like to understand how multiple sessions are processed in a Linux Web project.
For instance, does each session use a separate process, e.g. using fork()?
I ask because I see, using “htop”, that multiple sessions seem to appear under separate PIDs. Just want to make sure I don’t misread things here.
I’m using haproxy but currently, even though I have 2 apps running on two different ports, it often happens that two opened sessions run on the same app (and therefore seem to use only one CPU together) whereas the other app is idle, even though it could be using the other CPU.
However, if real processes (fork) are used even by one app’s each session, then I would not even have to run multiple app instances because then each process could run on its own CPU, right?
Correct. If you are using standalone, people usually use a load balancer or reverse proxy to distribute the clients. You just need to make sure that it has a way to direct a client back to the same instance of the app each time since the particular session will only exist there. Thats usually done with a cookie.