Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Websockets in PHP using Swoole

Websockets in PHP using Swoole

Ricardo Coelho

August 19, 2022
Tweet

More Decks by Ricardo Coelho

Other Decks in Programming

Transcript

  1. Ricardo Coelho - @ramcoelho
    Websockets in PHP using Swoole

    View full-size slide

  2. 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

    View full-size slide

  3. 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

    View full-size slide

  4. Ratchet &


    Swoole

    View full-size slide

  5. Concurrency,


    asynchony &


    parallelism

    View full-size slide

  6. Multithread,


    fibers &


    coroutines

    View full-size slide

  7. Shared memory &


    semaphores

    View full-size slide

  8. Websockets vs


    gRPC

    View full-size slide

  9. IP +
    Porta
    IP +
    Porta

    View full-size slide

  10. HTTP/2 &


    Streams,

    View full-size slide

  11. HTTP/3 &


    QUIC

    View full-size slide

  12. QUIC
    QUIC QUIC
    QUIC
    QUIC
    QUIC
    QUIC
    QUIC

    View full-size slide

  13. Ossification

    View full-size slide

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

    View full-size slide

  15. UDP
    UDP UDP
    UDP
    UDP
    UDP
    UDP
    UDP

    View full-size slide

  16. 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

    View full-size slide