How does web server process the requests?

Everything in PHP starts as a separate process. These processes are independent form each other until some shared resource comes in Picture.

In your case one user is handled one session and sessions are file based by default. The session file is shared resource for processes which means you can only make one call to PHP at a time for one user.

Multiple user can invoke any number of processes at once depending on your systems capabilities.


Laravel does not process requests directly, this is something managed by your webserver and PHP. Laravel receives a request already processed by your webserver, because it is only a tool, written in PHP, which processes the data related to a request call. So, as long as your webserver knows how to execute PHP and calls the proper index.php file, Laravel will be booted and process the request data it receives from the webserver.

So, if your webserver is able to receive 2 different calls (usually they do that in the hundreds), it will try to instantiate 2 PHP (sub)processes, and you should have 2 Laravel instances in memory running in parallel.

So if you have code which depend on anther code, which may take too long to execute depending on many other factors, you'll have to deal with that yourself, in your Laravel app.

What we usually do is to just add data to a database and then get a result back from a calculation done with data already in the datastore. So it should not matter the order the data get to the datastore, which one got in first, the end result is always the same. If you cannot rely on this kind of methodology, you'll have to prepare your app to deal with it.

enter image description here