In order to properly benchmark your shop, you need to check the settings of PHP, Apache and MySQL.
Try to use PHP >=7, it will speed up a lot your shop!
If you’re using PHP-FPM (which should be the case in most of “modern” installations), you have to check the pool
It’s usually stored in the file
Inside this file, the most important setting is the
pm.max_children setting. It must be greater than the max number
of concurrent users you want to simulate during the bench.
Make sure Zend Opcache is enabled.
Note this configuration of PHP should be used in Production environments only.
Use the following settings to optimize the performances:
[Date] date.timezone = UTC [Session] session.auto_start = Off [PHP] short_open_tag = Off realpath_cache_size = 4096K realpath_cache_ttl = 600 display_errors = Off magic_quotes_gpc = off ; Increase this value if you are able to do it memory_limit = 512M max_execution_time = 300 max_input_time = 300 upload_max_filesize = 20M post_max_size = 22M ; Increase this value if you work with products with a lot of combinations max_input_vars = 20000 allow_url_fopen = on [opcache] opcache.enable_file_override = On opcache.interned_strings_buffer=64 opcache.fast_shutdown=1 opcache.memory_consumption=256 opcache.max_accelerated_files=20000 ; Extra-optimization https://symfony.com/doc/current/performance.html#don-t-check-php-files-timestamps ; opcache.validate_timestamps=0
The class loader used while developing the application is optimized to find new and changed classes. In production servers, PHP files should never change, unless a new application version is deployed. That’s why you can optimize Composer’s autoloader to scan the entire application once and build a “class map”, which is a big array of the locations of all the classes and it’s stored in
Execute this command to generate the class map (and make it part of your deployment process too):
composer dump-autoload --optimize --no-dev --classmap-authoritative
--optimizedumps every PSR-0 and PSR-4 compatible class used in your application;
--no-devexcludes the classes that are only needed in the development environment (e.g. tests);
--classmap-authoritativeprevents Composer from scanning the file system for classes that are not found in the class map.
If you install a new module in production, you need to execute again this command.
If you’re using PHP-FPM, you should be enable to use apache mpm_event. Using the following configuration (to set in the mpm_event.conf file) should allow you to test up to 400 concurrent users:
ServerLimit 16 MaxClients 400 StartServers 3 ThreadLimit 64 ThreadsPerChild 25 MaxRequestWorkers 400 MaxConnectionsPerChild 0
If you using MySQL < 8 or MariaDB, enable the query cache by putting this setting in the
query_cache_limit = 128K query_cache_size = 32M query_cache_type = ON
Other important settings are:
table_open_cache = 1000 read_buffer_size = 2M read_rnd_buffer_size = 1M thread_cache_size = 80 join_buffer_size = 2M sort_buffer_size = 2M max_connections = 400 tmp_table_size = 32M max_heap_table_size = 32M table_definition_cache = 1000 performance_schema = OFF
Try to set the value of
innodb_buffer_pool_size to something greater than the size of your database on disk.
Before launching the benchmark, and after importing the data, it’s always great to launch an ANALYZE TABLE on all your database by running on your server:
mysqlcheck -a -A -uroot -pyour_password
Always try to use a CDN to reduce the amount of hits on your server. Cloudflare is a good and free service. You can use as well to minify your page or to easily enable SSL on your site.
In the performances tab of your prestashop: