Number of simultaneous requests that a PHP server supports

2

Let's say I have a server with an i7 processor with 4 cores / 8 threads.

On a multi-threaded architecture, assuming you create a thread on request, only 8 concurrent requests will be allowed, since the processor has 8 threads ?

If PHP servers are multi-thread , how can they respond to thousands of concurrent connections?

    
asked by anonymous 22.09.2017 / 20:01

2 answers

2

Do not. Simultaneous only the amount of existing processors. There is an illusion of simultaneity, as it does on your computer now. There are hundreds or thousands of processes running and it seems like everything is simultaneous, but it is not. There will be a change of execution.

The operating system schedules a thread at a time on each existing processor . Since the swap occurs very fast it seems superficially that they are running simultaneously, but if you do a basic time test you will see that it is not quite like this.

We're talking about processor. It turns out that a lot of the tasks involve input and output, so while reading or writing data externally to the processor it becomes idle then having multiple threads, much more than these 8 can be useful since while an > thread expects the external resource to respond to another that is not depending on which external resource it can execute, which helps to give the illusion of concurrency.

Actually today it is more common for applications to work asynchronously and not rely so heavily on threads to compensate for the use of external access.

Anyway, I have my doubts if a single server can handle thousands of "simultaneous" requests with PHP.

Node limits the virtual quantity of CPUs because it works asynchronously, you do not have to overuse threads because the CPU is triggered as needed, there is no need for CPU resource competition. It queues the requests in excess since it can not meet more than the capacity of the hardware, thus it saves with the management and for that reason it climbs much better, aside from the fact that the use is not so much in the "luck" of the moment. >

Node was known to do this, but all technologies do this today, often using libuv . People often do not understand much of what they are doing, they read something and think it is what is written without question, without understanding what is going on there.

Read Is it always guaranteed that a multi-threaded application runs faster than using a single thread? to understand better.

    
23.09.2017 / 15:11
1

Applications are not limited to processor threads and color. In fact only the operating system has access to these low level threads. And systems typically have APIs so that applications can create a virtually unlimited number of threads by dividing the CPU time between them.

    
22.09.2017 / 20:14