I use php and laravel as my web service.
I want to know does laravel store and process requests in these situation?
Is the laravel store these requests in a queue by the sequence the requests reached?
Is laravel parallel process requests for different users, and in sequence for the same user?
For example, there are two requests from the user. The two requests route to two methods in the same controller. While the first request will cost a long time for the server side processing, the second one will cost very little time. When a user set up the first request then the second one, though the second one cost very little time, the server side will not process the second request until it finish processing the first one.
So I want to know how does laravel store and process the requests?
The web server will respond, sending the browser the requested page, again, through HTTP. If the requested page does not exist or if something goes wrong, the web server will respond with an error message. The browser will then be able to display the webpage. Multiple domains also can be hosted on one web server.
The server opens a socket that 'listens' at port 80 and 'accepts' new connections from that socket. Each new connection is represented by a new socket whose local port is also port 80, but whose remote IP:port is as per the client who connected. So they don't get mixed up.
The messages sent by the client, usually a Web browser, are called requests and the messages sent by the server as an answer are called responses.
It starts either manually — when you enter an URL in the address bar of your browser — or programatically — by apps, websites (JavaScript), or other programs — and ends when response is received, and between that the magic happens. This is how we typically understand an HTTP request (an oversimplified representation).
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With