How to speed up a website by 4 times by simply reconfiguring the server

If you are working with a site that is gradually growing - the number of products increases, traffic from advertising - then sooner or later you will have to switch to highload operation mode, high server loads. But what if your site is not growing, and the server is increasingly failing, and data blocking occurs? It is with this problem that we faced, while finalizing the website for an online store of lighting equipment with an assortment of more than 100,000 products.





initial situation

The project was located on a server that had enough resources to ensure fast and smooth operation of the site, even under very high loads. However, the server did not respond to user actions or responded very slowly, as soon as the site traffic increased even slightly. 





Finding the problem 

We conducted an audit of the server and site settings, dividing the work into two stages: analysis of the back-end and front-end, and found a low page load speed on the back-end - about 80 seconds on the most visited pages, which ultimately led to a significant decrease in conversion.





We found out that the main problem was a misconfigured cache and database configuration.





As a result, a four-step action plan was drawn up, which helped us achieve good results. What have we done?





Decision

Step 1. Database setup

MySQL , . , , , SWAP, , , .





2. InnoDB

InnoDB?





InnoDB , MyISAM, . InnoDB .





InnoDB – InnoDB , MyISAM . , , / . , InnoDB .





InnoDB. , :





# InnoDB parameters







innodb_file_per_table







innodb_flush_log_at_trx_commit







innodb_flush_method







innodb_buffer_pool_size







innodb_log_file_size







innodb_buffer_pool_instances







innodb_file_format







innodb_locks_unsafe_for_binlog







innodb_autoinc_lock_mode







transaction-isolation







innodb-data-file-path







innodb_log_buffer_size







innodb_io_capacity







innodb_io_capacity_max







innodb_checksum_algorithm







innodb_read_io_threads







innodb_write_io_threads







1 2 - , . 





.





3. Nginx brotli, pagespeed, proxy_buffering

Nginx , , . Nginx , , , Mail.Ru, . , Nginx (proxy_buffering) (proxy_cache), .





Nginx. - , , , . client_max_body_size, Nginx .





4. PHP-FPM Memcache Apache

PHP-FPM - Nginx. , PHP-FPM. , Nginx + Apache.





Apache . , Apache , . Apache, , .





PHP-FPM unix socket. ? Nginx -, . PHP-FPM. , unix socket – PHP-FPM, .





1. 24 3 ,   5-8 .





2. .





3. - .





4. 30%, , S, : => => => .





5. front-end . :





  • webp;





  • lazyload- ;





  • .





We made the site faster and fixed loading issues without changing the code. The speed of the site affects many indicators: from user friendliness to the ranking of the site in the search results, which ultimately affects the conversion.








All Articles