Mateus Guimaraes brought a deep-dive through how Laravel Octane can massively improve performance of your apps.
Main benefits:
- Reduced latency by eliminating the framework boot step on every request
- Increased performance
- Lower cost by reducing CPU usage
Aaron Francis asked a followup question about which driver is best:
- Swoole is better tested and supported by some higher-profile companies (see also OpenSwoole)
- FrankenPHP looks promising
None of the apps I’m currently working on need this level of performance (yet) but I’d be interested to try Octane to see how it could improve performance even now.
One more note: Octane can run multiple processes concurrently to save time during a request:
<?php
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Route;
use Laravel\Octane\Facades\Octane;
Route:: get('foo', function () {
Octane::concurrently([
fn () => DB::select('SELECT * WHERE SLEEP(1)'),
fn () => DB::select('SELECT * WHERE SLEEP(1)'),
fn () => DB::select('SELECT * WHERE SLEEP(1)'),
]);
return ['foo' => 'bar'];
});