• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Server Plesk configuration for eCommerce in PrestaShop

Loris Modena

New Pleskian
I would like to know how to optimize the configuration in order to increase performance especially with regard to database requests. The server at my disposal is as follows:

Server OVH Enterprise SP-32
Linux Plesk 12.5 (Cent OS 7)
Intel(R) Xeon(R) CPU E3-1231 v3 @ 3.40GHz – Core: 8
32 GB RAM
2x2000GB SATA
Network: 1Gbps (500 Mbps)

summary.jpg


velocita-sound.jpg


The need is to manage a single ecommerce on PrestaShop and with an Ap PageBuilder theme.
Did I denoted differences from a server with less RAM and older CPUs, how and where to configure it?
I find many tips on the web, but they do not lead to real improvements.

Current configuration:
PHP 5.6.30 - FPM Apache
memory_limit: 2048M
max_execution_time: 300
max_input_time: 300
post_max_size: 256M
upload_max_filesize: 256M
opcache.enable: on
max_input_vars = 15000; //to manage prestashop translations

Intelligent file static processing: disable

Additional Nginx Directives:
proxy_buffer_size 256k;
proxy_buffers 8 512k;
proxy_busy_buffers_size 512k;
fastcgi_buffer_size 256k;
fastcgi_buffers 512 8k;
fastcgi_busy_buffers_size 512k;
fastcgi_temp_file_write_size 512k;
fastcgi_connect_timeout 600;
fastcgi_send_timeout 600;
fastcgi_read_timeout 600;
proxy_connect_timeout 600;
proxy_send_timeout 600;
send_timeout 600;

my.cnf
[mysqld]
#bind-address = ::
bind-address = 127.0.0.1
skip_name_resolve
local-infile=0
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
performance_schema = on
slow-query-log = 1
slow-query-log-file = /var/log/mysql/mysql-slow.log
long_query_time = 1
log-queries-not-using-indexes
key_buffer = 512M
join_buffer_size = 48M
query_cache_size = 8M
query_cache_type = 0
query_cache_limit = 2M
tmp_table_size = 2048M
max_heap_table_size = 2048M
thread_cache_size = 4
innodb_buffer_pool_size = 3072M
innodb_file_per_table = ON
table_open_cache = 500
innodb_buffer_pool_instances = 3
 
The "Wait" time on the Pingdom speed test in your case indicates the time that the PHP scripts of Prestashop need to process data and send the result to the web server. From my experience, this time can only be reduced by detailed script optimization, e.g. remove unnecessary loops, reform SQL statements, use optimized functions like array_walk() instead of foreach() and so on. Your issue will likely be 3rd party components that are often programmed very bad and do not pay any attention to performance.

Optimizing server settings will NOT lead to success. It might reduce the "Wait" time a tiny little bit, but almost unnoticeable, for example you can reduce maybe 50 to 80 ms, but this means that instead of 1.46 seconds you'll still wait 1.38 seconds. The big savings can only be made by micro-optimizations of the code.

Some hints:
Nginx:
- Enable smart proxying of static files (by the checkbox in Plesk)
SQL code:
- use set operator IN instead of conjunctions of LIKE wherever possible.
- use LIMIT to limit the number of sets retrieved to the number the script expects
- use indexes on fields that need sorting or are part of WHERE statements
PHP code:
- Use PHP 7 or 7.1 instead of 5.6 if your software supports it (it is much faster by default)
- check all loops (while, foreach) and make sure that inside the loops only the minimum number of transactions are done
- solve errors instead of suppressing error messages to logs
- use single instead of double quotes wherever no in-string variable interpretation is needed
- use identity versus equality comparisons wherever possible (=== operator instead of ==)
- use trinity operator instead of if-then-statements (e.g. $myvar = $i == 1 ? 'yes' : 'no')
- sort the order of if-then-statements that the most likely to succeed is on top
- remove unneccesary brackets
- remove unnecessary optional parameters
- use as little global variables and global definitions as possible
- transfer variables by pointer to functions instead of transferring the content (e.g. myfunction (&$myvar))
- avoid regular expressions wherever possible
- on string replacements use one str_replace statement and arrays in it instead of using many replace statements
- use ++$i instead of $i++ or $i+=1
- use array_map() instead of foreach()
- use htmlspecialchars() instead of htmlentities()
- use echo() instead of print

Incomplete list, but you are getting the idea what this is about.
 
Back
Top