PHP-FPM vs Swoole execution model

preview_player
Показать описание
Note: I used async I/O and non-blocking I/O interchangeably, but they're not the same thing. Async I/O is a way to implement non-blocking I/O.
Note 2: I'm sorry some words are cutting off. I had my preamp improperly configured.

👨‍💻 Learn Test-Driven Development with Laravel!

👨‍💻 Sign up to my newsletter and receive PHP, JS and Laravel news in a weekly-basis:

🎉 Party up:

Thanks for watching!
Рекомендации по теме
Комментарии
Автор

By far the biggest thing to be aware of with Swoole is that if your code encounters an error, the entire worker has to be restarted, which kills all requests that it had been handling concurrently at that time. In FPM, just that request is affected. You have to be a LOT more defensive with your code in Swoole, which can be difficult sometimes due to PHP's ancient error model.

pfqniet
Автор

12:26 "you cannot use two workers to. handle the same request". Yes in this case you are right. What about with PHP ZTS? We can have multiple threads to achieve true parallelism. Any input on that?

magnetoflux
Автор

Informative video, thank u so much. please continue this kind of video.❤

DevAmirull
Автор

Very detailed. Thanks!!!! Now you should compare swoole with frankenPHP.

jleonardolemos
Автор

I had an experience recently that was left behind by another programmer, which was basically the "if db record exists, do this" problem where there were multiple requests (the project was in Laravel and had php-fpm on nginx) and this caused the insertion of two or more records, duplicates, triplicates, etc. That's because the db is a shared resource, right? Although php is 'shared nothing'?

fanty
Автор

Does anybody know how to install swoole in macos using brew ?

TariqSajid
Автор

Hey dude, appreciate the video and all the effort into the quality of the presentation. Regarding FPM's manager process being blocking. You state: "It's also not very effecient, because the requests are blocking." that's not really right. I/O operations are not blocking with PHP FPM. Try executing an expensive query in one PHP request while making requests to another endpoint. You'll notice it's not blocking. But why? The reason is that there's an event loop the same way a node.js server would be able to handle many many requests simultaneously without blocking.

Note: One possible gotcha in PHP is that sometimes sessions can cause blocking due to how sessions are configured, where the session file for a user may be locked and prevent other requests from executing. Mattias Geniar has a good write up on this issue. One way to easily prevent this from affecting the test above is to open the requests in separate browsers or use incognito mode for one session.

kevanschwitzer
Автор

This was amazing. Please make more content like this

AmitErandole
Автор

oh why oh why do I have to program in PHP. Great video btw

evergreen-
Автор

So can you show us what changes when we write code for workers, api calls and controllers?

AmitErandole
Автор

Congratulations. Is It possible to replicate this video in PT-BR?

luizdanin
Автор

good content, thank you for taking the time to explain this, but please work on your writing/drawing skills space things out more

GeorgianMatei