Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
1. You can have multiple processes with 1 eventloop each.
2. With php the whole framework has to be initialized on each request (with crap like laravel this becomes a massive overhead). (Plain php is fast enough but if you start using semi large frameworks even "slow" languages like python comes out on top perfprmance wise since they don't do stupid shit over and over again. -
anekix3946yStart by looking differences between multi threading & multiprocessing. Process are heavier to start and take more memory, to share memory you have to use some weird techniques which is not the problem with threads ( they have their own issues like proper synchronization ) .So we generally resort to having multiple threads in languages that do support them like( Java ,c++) .For single threaded languages ex javascript(& those which does not have true threading support like Python) we use event driven mechanism ( so called event loop) to achieve concurrency( event loops can be implemented in different ways..In Python it's attained by creating a scheduler that switches between coroutines ).in short using multiple process to handle multiple requests( like Apache does by default) is the least preferred way and rarely used when performance is a key metric.
-
anekix3946yAlso it's a wrong statement to say that event loop is faster than using multiple processes or vice versa because that is meaningless.
The difference is usually measured in terms of no of requests that each method is able to serve in a given time. For process based systems usually there is a limit on number of processes that can be spawned. -
@anekix very well explained. It makes sense when thinking in terms of number of request instead of speed of execution.
I do not understand how event loop of node is faster than per request new php fpm process or similar.
Imagine you have 10 users surfing your website. In PHP there will be 10 process working on each request.
Where as in NodeJS there is only 1 process taking each request one by one.
Now for the I/O part, it is going to take same time on completion. By the time the IO is completed and the control is back to NodeJs, It will eventually take the same time (the actual response delivered).
Am I missing something here ?
question