* Why and How to utilize asynchronous in PHP
* How to implement a simple asynchronous server with PHP C extension
* Production ready, large-scale asynchronous programming with PHP language and Swoole
• Originally created as a templating language • Thread/process based model • Blocking IO and Sync • Stateless and scalable • FastCGI • Process per connection is memory expensive • Build up everything then destroy everything • Triggered by user request (No scheduler) • Process per connection is easy for 504 timeout
No IoT (asynchronous I/O) Huge Ecosystem Difficult to implement Server side protocol and services: TCP Socket, SMTP, MQTT, WebSocket, Thrift, etc Sync Simple and easy Sync One wait stop all Stateless Stateless Scalable Low performance Robust No long-live connection No pooling
flag and return the status of all sockets, manually iterate through all the fds (C10K problem) • poll() similar to select() but allocate an array of pollfd, can handle more than 1024 sockets •epoll() monitors sockets’ status and trigger related events, and only return triggered events array.
High concurrency, large number of connections • Long-live connections, real-time services • Long-live connections to DB, Cache, RPC etc • Support more server side protocols • Server side programming • Scheduler • Async tasks need 3rd party services • Manage and reuse the status in memory • Performance
server • Websocket server • TCP server • High performance services • High concurrency systems (C100K) • Internet of things server • Compete with language X, Y, Z