Taylor Otwell gave Laracon Online 2021 attendees a first glimpse of Laravel Octane—a unified first-party package for running highly performant Laravel utilizing environments like Swoole and RoadRunner.
Octane delivered roughly 6,000+ requests per second in some "hello world" examples under a load of ~50 concurrent requests using four concurrent threads during the demo.
WOW.— Laracon Online (@LaraconOnline) March 17, 2021
With the Octane Swool server running, 6000+ requests being handled by the framework.
That's insane! pic.twitter.com/FGYoghib2D
Here's an example of the wrk command used during the demo as a rough benchmark example:
wrk -t4 -c50 http://localhost:8000/hello-world
How Does it Work?
Octane's entry point is an Artisan console command(
octane:start) that will run either Swoole or RoadRunner. You can specify which technology to use and how many threads to run based on your environment's CPU threads:
artisan octane:start --workers=8 --server=roadrunner
Swoole and RoadRunner utilize coroutines that enable PHP to run more efficiently by forking several worker processes based on CPU core numbers. Using Swoole/RoadRunner allows better app startup efficiency, coupled with PHP OPcache to minimize overhead by storing byte code in shared memory.
PHP workers remain active between requests (you can cycle them after "x" requests via artisan flag) and are ready to receive new requests. Eliminating framework startup time has a significant impact on performance for applications with heavy HTTP workloads.
What is the Purpose?
Typical applications don't demand outlandish requests-per-second we see in these early demos of Octane. However, the need for high availability PHP applications is common, and Laravel is in a unique position to guarantee that framework-level code works seamlessly with tools like Swoole and Octane.
First-party support from Laravel for these technologies will be a considerable breakthrough in modern approaches to scaling PHP applications. The entire PHP ecosystem will benefit from these efforts.
When will Laravel Octane be released?
The first version of Laravel Octane was released since May 12th, 2021.
Full stack web developer. Author of Lumen Programming Guide and Docker for PHP Developers.