×

You are here: Home > FAQ > VPS small memory optimization suggestions (LNMP + WordPress environment)

FAQ

VPS small memory optimization suggestions (LNMP + WordPress environment)

For VPS, the memory should be one of the most valuable resources, and smaller memory prices are more cheaper, ordinary users are more able to accept. Therefore, how to effectively use the limited memory resources to maximize the utilization of VPS, can carry a higher number of concurrent and load, it should be all VPS users are thinking about the problem. Below, combined with some experience in the maintenance of the site, I get the time to give some relevant suggestions, of course, this proposal is mainly aimed at optimizing the Linux environment and WordPress users.

- Stable VPS servers
are all relying on the contents of the upper stable hardware support, so if you buy the line VPS hosting giant slow, hang every few days, or sometimes VPS machine tools IO load high, then, even then how to optimize it no use, you all day doing things that made ??Ticket to find customer service to solve the problem. So, buy a fast and stable VPS Hosting This is the most basic requirement.

- Lightweight Web Server
Apache has become increasingly bloated, and memory overhead is very large, so the individual is recommended to use lightweight Nginx servers, but for WordPress for nginx has been completely sufficient. Here are the rules applicable to WordPress nginx rewirte 3, including Permalinks rewrite and WP-super-cache rewrite rules.

The PHP side is recommended to use PHP-FPM, PHP-FPM is already included in PHP 5.3.3, for the small memory VPS user is recommended to use a static process approach, which is a fixed number of processes, and recommended less open several processes, such as 4 -6 or so.

Can be installed directly on Ubuntu with the following command nginx, php-fpm, mysql environment

sudo apt-GET install nginx php5 php5-dev php5-fpm php5-mysql mysql-Server make

- take advantage of multicore

Nginx has a worker_cpu_affinity parameters on Linux, you can bindings for each worker process to a different CPU, so if you have a multi-core VPS, then you can take advantage of each CPU. For example, if you have 4 CPU, you can perform the following configuration:

worker_processes 4;
worker_cpu_affinity 0001 0010 0100 1000;

Finally, you can look at the CPU status, the test method is to enter the top command and press 1.

- MySQL optimization

turn off InnoDB: If the VPS is only used to run Worpdress, then use the MyISAM storage engine is sufficient. You only need to add a line skip-innodb in my.cnf can put InnoDB storage engine to turn off. This can save a certain amount of memory.

- Cache, then the cache
enable PHP caching acceleration module eAccelerator: we all know, PHP is a dynamic scripting language, each visit will re-compile and run, but you can cache the compiled eAccelerator part of PHP files to play to improve the performance of PHP scripts and the effect of reducing the system load. But note that, under nginx + PHP-FPM environment, eAccelerator memory can not be shared, meaning that each process PHP-FPM in addition to its own memory overhead needed, it will also set the parameters plus eaccelerator.shm_size given value, so we try to decrease the value of eaccelerator.shm_size when setting, such as setting is 8 MB, so a maximum cache多个50 php file, although lacking, but it is basic enough for WordPress, which also considered a conservation of resources and increase the performance of compromise. In addition, the access speed to enable eaccelerator does have improved significantly.
WordPress page caching: It is recommended to use Wp-super-cache plugin has been mentioned before nginx rewrite the rules of the plug-in. Wp-super-cache static page cache can play the effect can be further addition to low system load.
Database query cache: In order to further reduce the number of database queries, you need to use these plug-ins, these plug-ins are many, and I use the DB Cache Reloaded.

- WordPress templates and plug-ins  
to reduce unnecessary plug-ins and templates with simple, do not put a lot of pictures, because once the picture more than one will produce more http connection requests, resulting in slower page load load, but also consumes more more bandwidth, bandwidth is after all one of the important resources of VPS.

# Finally, some online testing and optimization tool:
Just-Ping: ping can get dozens of locations around the world, while the value of your host, which can determine the line quality VPS host.
Pingdom: full page load testing tool that can test access to a web page and co-sponsored a number of requests per time-consuming requests, which can determine which page elements affect the loading speed comparison, for further optimization to help.