Slide 1

Slide 1 text

Ricardo Coelho - @ramcoelho Websockets in PHP using Swoole

Slide 2

Slide 2 text

Agenda Websockets & HTTP/1.1 Ratchet & Swoole Concurrency, asynchrony & parallelism Multithread, fi bers & coroutines Shared memory & semaphores Streams, gRPC, protobuf, HTTP/2, HTTP/3 & QUIC

Slide 3

Slide 3 text

Websockets

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Supervisor

Slide 6

Slide 6 text

FROM php:8.1.9 RUN 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 sockets nexy/swoole:8.1.9

Slide 7

Slide 7 text

Ratchet & Swoole

Slide 8

Slide 8 text

No content

Slide 9

Slide 9 text

Concurrency, asynchony & parallelism

Slide 10

Slide 10 text

Multithread, fibers & coroutines

Slide 11

Slide 11 text

Shared memory & semaphores

Slide 12

Slide 12 text

Websockets vs gRPC

Slide 13

Slide 13 text

HTTP/1.1

Slide 14

Slide 14 text

TCP/IP

Slide 15

Slide 15 text

IP + Porta IP + Porta

Slide 16

Slide 16 text

TCP/IP

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

No content

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

HTTP/2 & Streams,

Slide 21

Slide 21 text

Multiplex

Slide 22

Slide 22 text

TCP/IP

Slide 23

Slide 23 text

No content

Slide 24

Slide 24 text

HTTP/3 & QUIC

Slide 25

Slide 25 text

QUIC QUIC QUIC QUIC QUIC QUIC QUIC QUIC

Slide 26

Slide 26 text

Ossification

Slide 27

Slide 27 text

“Respect the past, and prepare for the future by taking action in the present.” Rob Martin

Slide 28

Slide 28 text

UDP UDP UDP UDP UDP UDP UDP UDP

Slide 29

Slide 29 text

Performance

Slide 30

Slide 30 text

Conclusion

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

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/swoole The WebSocket Protocol QUIC: A UDP-Based Multiplexed and Secure Transport Hypertext Transfer Protocol Version 2 (HTTP/2) HTTP/3 Images Ratchet Websockets Open Swoole These slides Code used in these slides