How does a web project manage multiple sessions?

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?

By default, WebSessions are all Xojo Threads. If you have multiple processes running, you are either using cgi or your reverse proxy is set to launch multiple instances of the app.

There is no forking going on in the app.

Thanks for clarifying. So, to use multiple cores, it is still prudent to run multiple app instances on different ports, right? Or use cgi, as then the web server handles their invocations?

Yes, we run for one client 4 copies of the app and use a little script to distribute people:
https://www.mbsplugins.de/archive/2019-03-03/Simple_load_balancer_for_Xojo_

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. That’s usually done with a cookie.