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

How Swoole Blows Up Your Mind

Albert Chen
December 20, 2022
210

How Swoole Blows Up Your Mind

PHPCon Okinawa 2019

Albert Chen

December 20, 2022
Tweet

Transcript

  1. About Me • Albert Chen • Software Architect • M17

    HandsUp • Open Source Maintainer
  2. What is Swoole? • A C extension for PHP •

    An asynchronous network engine for PHP • Features: • Event-driven non-blocking I/O • HTTP / HTTP2 / Websocket / TCP / UDP • Coroutine (CSP Model) • High performance for high concurrency
  3. Lifecycle in PHP PHP
 Files Tokenizing Semantic Parsing AST Generate

    Bytecode Execute Bytecode Output Load Bytecode From Memory Check Bytecode Cache
  4. Blocking I/O in PHP Request Request Request Request PHP FPM

    FPM Pool FPM Pool Worker Worker Worker Worker Blocking I/O
  5. Structure in Swoole Server • Code Is Persistent in Memory

    • Swoole Takes Lifecycle Over PHP • Reduce Initialization Steps • Reduce Response Latency • Event-driven Non-blocking I/O for Requests
  6. Use Case Facebook Webhooks Message Load Balancer Server Server Server

    Queue PubNub
 Service Analysis Service Swoole Service PubSub Many to Many Queue Workers High Concurrent Requests
  7. Q&A