Increase Laravel performance — Part 1 Opcache!
Hi there, I ‘m Masoud Tavakkoli and today we want to talk about increasing PHP and Laravel Performance by 5x using swoole extension…
Hi there, I ‘m Masoud Tavakkoli and today we want to talk about increasing PHP and Laravel Performance by 5x using swoole extension.
Laravel is a free, open-source PHP web framework, created by Taylor Otwell and intended for the development of web applications. Laravel reuses the existing components of different frameworks which helps in creating a web application. The web application thus designed is more structured and pragmatic.
Why Laravel…?
As mentioned before laravel is great framework and has a very big community of developers. In recent years a lot of packages, tools and projects built for laravel.
yesterday was laravel 10th birthday!
Why not…?
Although Laravel is a perfect modern framework, it has significant weaknesses that cannot be ignored. Compared to industry competitors, Laravel has a high overhead in response time. Laravel is a big truck with a lot of features and as expected it can’t drive fast!
How to increase performance of Laravel application?
In recent years with the release of PHP 7, performance was greatly improved and it changed the way PHP was used.
I. Opcache (Easy):
Installation
- CentOS:
sudo yum install php-opcache
- Ubuntu/Debian:
sudo apt install php-opcache
- Shared Hosting: Ask your provider to enable
first enable opcache extension in php.ini
. The following settings are generally recommended as providing good performance:opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=4000
opcache.revalidate_freq=60
opcache.fast_shutdown=1
opcache.enable_cli=1
II. PHP-FPM Config
If you are using php-fpm for serving your application, reconfigure your fpm has a lot of improvement in your application performance.
Notice: This config highly depends on your server resources so be careful.
open `/usr/local/etc/php-fpm.d/www.conf`
Thats it!
Let me know what you think.
Comments ()