Ricardo Coelho - @ramcoelhoWebsockets in PHP using Swoole
View Slide
AgendaWebsockets & HTTP/1.1Ratchet & SwooleConcurrency, asynchrony & parallelismMultithread,fibers & coroutinesShared memory & semaphoresStreams, gRPC, protobuf, HTTP/2, HTTP/3 & QUIC
Websockets
Supervisor
FROM php:8.1.9RUN apt-get update \&& apt-get install -y libssl-dev git zip wget \&& cd /tmp \&& wget https://github.com/swoole/swoole-src/archive/refs/heads/master.zip -O swoole-src.zip \&& unzip swoole-src.zip && cd swoole-src-master \&& phpize && ./configure && make && make install \&& cd / && rm -rf /tmp/pear \&& docker-php-ext-install sockets \&& docker-php-ext-enable swoole socketsnexy/swoole:8.1.9
Ratchet &Swoole
Concurrency,asynchony ¶llelism
Multithread,fibers &coroutines
Shared memory &semaphores
Websockets vsgRPC
HTTP/1.1
TCP/IP
IP +PortaIP +Porta
HTTP/2 &Streams,
Multiplex
HTTP/3 &QUIC
QUICQUIC QUICQUICQUICQUICQUICQUIC
Ossification
“Respect the past, and prepare for thefuture by taking action in the present.”Rob Martin
UDPUDP UDPUDPUDPUDPUDPUDP
Performance
Conclusion
References• https://www.rfc-editor.org/rfc/rfc6455• https://datatracker.ietf.org/doc/html/rfc9000• https://www.rfc-editor.org/rfc/rfc7540.html• https://datatracker.ietf.org/doc/html/rfc9114• https://unsplash.com• http://socketo.me• https://openswoole.com• https://speakerdeck.com/ramcoelho/swoole• https://github.com/nexy/swooleThe WebSocket ProtocolQUIC: A UDP-Based Multiplexed and Secure TransportHypertext Transfer Protocol Version 2 (HTTP/2)HTTP/3ImagesRatchet WebsocketsOpen SwooleThese slidesCode used in these slides