What Makes Laravel Slow? • A large amount of files are required. • Each file needs its parsing and compiling. • Compiled results will be destroyed after the request. • The default session driver of Laravel is file. • Laravel is a full-stack framework. • All the resource can not be reused.
Integrating Solutions ① Only use Swoole like PHP-FPM. ② Preload and share single Laravel application. ③ Reset necessary classes/variables based on ②. ④ Build sandbox app for request process based on ③. Running on Package
Integrating Solutions Autoload Load App Bootstrap Register Service Providers Boot Service Providers Http Kernel Middleware Dispatch by Router Routes Match Controller Response Terminate Middleware Request public/ Laravel will be only booted at the first time. ② Preload and share one Laravel application.
Integrating Issues ① Laravel application will be booted only at the first time. ② All the singleton classes, global or static properties will be preserved in the memory. ③ Developers need to reset these polluted variables manually.
Integrating Issues ① There are too many unpredictable singleton instances. ② Some code will make app become dirty. ③ Some dependency properties are not easy to reset. ④ Damned static variables…
Laravel Swoole • Run Laravel/Lumen application on top of Swoole. • Outstanding performance boosting up to 5x faster. • Sandbox mode to isolate app container. • Support running websocket server in Laravel. • Support Socket.io protocol. • Support Swoole table for cross-process data sharing. • Support Coroutine (in develop).
Connection Pool for Coroutine • Each pool maintains several connections. Connection Connection Connection Connection Connection Connection Connection Pool Worker Database