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

Hypervel - A Coroutine Framework for Laravel Ar...

Hypervel - A Coroutine Framework for Laravel Artisans

@PHPCon Japan 2025

Avatar for Albert Chen

Albert Chen

June 26, 2025
Tweet

More Decks by Albert Chen

Other Decks in Programming

Transcript

  1. 02 Limitations of Laravel Octane Outline 01 Introduction of Laravel

    Octane 04 Coroutines in Hypervel 05 Benchmark Comparison 07 Q&A 06 Live Demo 03 Introduction of Hypervel
  2. 🙍‍♂️ I’m Albert Chen 💻 Software Architect based in Taiwan

    🐘 Laravel Artisan ⚡ Swoole Enthusiast 🧙 Hyperf Contributor 🧙 Creator of Laravel Swoole (archived) 🧙 Creator of Hypervel X: @albert_cht Who am I?
  3. Published in April 2021 Maintained by official Laravel team Supports

    Swoole, Roadrunner and FrankenPHP as drivers Requires Laravel 10 and PHP 8.1 in 2.x Supercharge performance of Laravel Hot reload support Additional features in Swoole driver: Concurrent Tasks Ticks and Intervals The Octane Cache Swoole Table What is Laravel Octane?
  4. Request PHP Startup Framework Bootstrapped Handle Request PHP Terminate What

    is Laravel Octane? Workflow in traditional stateless PHP-FPM Response Heavy Task
  5. Request Response What is Laravel Octane? Workflow in stateful Laravel

    Octane PHP Startup Reset States Handle Request PHP Terminate
  6. Boost your Laravel application up to 5x faster in QPS

    With lower response latency What is Laravel Octane? Is Laravel Octane Always Fast? (Mac M1 Pro 2021, 8 CPU, 16G Ram)
  7. Consider building an LLM-powered chatbot with Laravel Octane Building a

    Chatbot https://x.com/heytjmiller/status/1928808983239733359 Prism https://prismphp.com
  8. Consider building an LLM-powered chatbot with Laravel Octane If each

    request takes about 3-5 seconds How many concurrent requests can Laravel Octane provide? LLM response takes time... Building a Chatbot
  9. Laravel Octane only decreases the response latency by keeping bootstrapped

    framework in the memory I/O requests in Laravel Octane are still blocking Processes will be blocked until the end of the I/O 80% of requests in the web application are I/O bound Laravel Octane doesn’t help in blocking I/Os at all Laravel is not suitable for handling I/O bound requests in high concurrency even with the help of Laravel Octane Limitations of Laravel Octane
  10. It’s a bad idea to build LLM-based chatbots in production

    with blocking I/O in PHP even with Laravel Octane The only way to increase QPS is to scale your machines It’s extremely inefficient for the machine resource and cost Limitations of Laravel Octane
  11. Main yield Waiting resume Main process doesn’t get blocked while

    waiting for I/O Coroutine in Laravel Octane Blocking I/O vs. Non-blocking I/O Main I/O call Waiting return Main process gets blocked while waiting for I/O
  12. Coroutine in Laravel Octane Does Octane support coroutine with Swoole?

    No, it’s highly risky! Laravel is designed for stateless environment States bleeding among coroutines will be a mess in Laravel Event if Laravel supports coroutines within single request , the worker is still occupied until the end of all I/O operations Laravel team has little possibility to support coroutine due to the considerations of the current ecosystem and backward compatibility It’s not a package-level thing, it’s about the whole framework and related ecosystem
  13. This project was launched in 2023 Initially crafted for internal

    use in my team, aiming to help Laravel artisans enjoy the high performance of coroutines while maintaining familiar Laravel development practices Ported bunch of packages from Laravel to support coroutine Reduce the learning cost for a new framework Share the same package ecosystem with Hyperf framework What is Hypervel? https://github.com/hypervel/hypervel
  14. What is Hypervel? Auth Hypervel Framework Broadcasting Bus Cache Config

    Console Container Cookie Coroutine Dispatcher Encryption Event Filesystem Foundation Hashing Http Client JWT Mail Log Notification Object Pool Process Prompts Router Queue Session Support Translation Validation Testbench Telescope
  15. What is Hypervel? We ported most of the components from

    Laravel to make them coroutine-safe in Hypervel Packages from Hyperf are compatible with Hypervel Some components provide similar usage while keeping compatibility with Hyperf framework Requests, Responses, Cookies Laravel packages are NOT compatible with Hypervel
  16. Coroutine in Hypervel Resolved User Request Lifecycle A&B User A

    Request A Request B 1 2 User B Unlike Octane, states in shared objects are isolated via Context
  17. Coroutine Supports Automated yield an resume while switching I/O states

    Runtime Hooks Channel (CSP Model) Defer WaitGroup Parallel Coroutine Context Coroutine in Hypervel which can’t be achieved in other async libraries
  18. 1 2 2 Coroutine in Hypervel Global States Bleeding in

    Coroutines Global states are shared in coroutines That’s why Laravel can’t support coroutines
  19. Polyglot Stack If you already have lots of projects built

    with Laravel... How to migrate to Hypervel?
  20. Load Balancer Laravel Hypervel Polyglot Stack You can integrate Hypervel

    with your Laravel projects Share Data and Communicate
  21. Communication in Polyglot Stack Cache, locks and queues can be

    shared between Laravel Laravel Cache Hypervel Cache Hypervel Lock Laravel Lock Same Communication Protocol Hypervel Queue Laravel Queue Payload
  22. Benchmark Comparison More than 10x faster than Laravel Octane in

    QPS Lower response latency (Mac M1 Pro 2021, 8 CPU, 16G Ram) Laravel Octane Hypervel Hello World Test
  23. 1s I/O Test Benchmark Comparison Hypervel is excellent at I/O

    requests with coroutines (Mac M1 Pro 2021, 8 CPU, 16G Ram) Laravel Octane Hypervel
  24. Q&A