4.3.4. Acceleration and optimization of VPS (general recommendations)

Site optimization (the work of his scripts, pages) - the highest priority option. It is recommended to start with it.

This option includes not only fine-tuning the software included in the standard installation (Apache web server, MySQL, PHP), but also the installation of various kinds of accelerators and changing the software configuration. The most popular options:

  • Disable unused services — by default (especially if the preinstalled software is used) a lot of services (daemons) are running, which may not be used by your site in any way. They should be disabled — this will free up a certain amount of server resources.
  • Installing nginx — is placed in front of Apache and takes over the processing of static files, reducing the load on the server and increasing the speed of serving such files.
  • Installing the PHP accelerator (for example, OPcache) — after installation, this service caches the pre—compiled bytecode, thereby speeding up the execution of PHP scripts and reducing the overall load on the server.
  • Installing Memcache (d) — it allows you to cache data not on the disk, but in the server's RAM. What exactly and how to cache depends on the site scripts. Usually they configure caching of the most frequent MySQL queries, intermediate results of PHP scripts execution, sometimes — pre—created pages. It is useful in that due to the use of very fast RAM, data is written / sent almost instantly.
  • Switch PHP to FastCGI mode or use PHP-FPM — this significantly reduces the load on the server and allows it to work more stably.
  • Installing the PageSpeed module — this module from Google developers does not so much reduce the load on the server as it optimizes the data given to site visitors, thereby speeding up its work. However, configuring this module requires special care in the rules used, since incorrect configuration can lead to various errors.

Another option, which is specially rendered separately — a complete rejection of the use of the Apache web server (slow, "heavy" in terms of resource consumption) and its replacement with a bundle nginx+PHP-FPM... It is very fast, economical, but requires serious enough skills to correctly configure such a solution.

The last way to solve the problem is to increase the server capacity.

Provided that a server of adequate configuration was initially selected for the site, this is indeed the very last method. And it is worth resorting to it only in the most extreme cases, when all the others have exhausted themselves.

Unlike the previous methods, which require you to perform optimization work once (for money or on your own) and for a long time "forget" about the problem, buying a more powerful server is not even a solution to the problem, but self—deception. Elimination of symptoms, but not treatment of the disease. Sooner or later, site traffic will grow, there will be more content, and again you will have to spend even more money on a new, even faster server. Performing optimization actions will allow not only to reduce costs (even if you have to pay for the services of optimization specialists), but also to achieve better site performance than in the case of a simple increase in server capacity.