Introduction to 3 ways to improve wordpress speed

In the tomb of the gods, Shoumang said to Yun Tianhe, who just got the shot of the Japanese bow. "Today begins, after the slap shot, the bow bows to you, the power is limited, the master is the same!" The wordpress is the same, can't run Fast, depending on the owner. Today, from the framework layer to talk about the speedup optimization of the wordpress blog.

Introduction to 3 ways to improve wordpress speed

Nginx optimization

There are a lot of HTTP server software to choose from, and each has its own advantages and disadvantages. The two most popular ones are Nginx and Apache. If Apache is Apache, Nginx is su37 (of course not su37 in the top secret flight of the movie by the drone EDI), Apache's maneuverability is not the same as su37, Apache performance and Nginx also have a certain gap.

So today we choose Nginx as the HTTP server. Nginx has three major impacts on web page speed: http/2, Gzip, and Keep-alive.

Nginx enables Gzip

Gzip has a qualitative leap in the speed of loading text files, even directly affecting the speed of the first screen, and can save at least 40% of the cost of traffic.

Gzip on;gzip_min_length 1k;gzip_buffers 4 16k;gzip_http_version 1.0;gzip_comp_level 6;gzip_types text/plain application/x-javascript text/css application/xml application/javascript;gzip_vary on;

If the system CPU load is not heavy, the value of gzip_comp_level can be set to 6, which is generally set to 4. The larger the value, the better the compression effect, but the more CPU.

Keep-alive

Keep-alive is also called HTTP persistent link, which means that a TCP/IP link carries multiple uplink and downlink requests. Compared to the traditional single-link mode (a mode in which a single BS link is required to be created), Keep-alive technology has a significant performance boost. Here are the advantages of Keep-alive technology.

1) The CPU and memory load will be reduced, because the number of TCP links opened at the same time is reduced, and subsequent requests and responses do not need to open new links, and can continue to send uplink and downlink data based on these TCP links.

2) When the TCP link is established, the waiting time of the request will be reduced, and the three-way handshake when the TCP establishes the link occurs between the user side and the server. When the handshake is successful, a TCP link is established. In Keep-alive mode, the handshake is one-off, which happens when the link is established. The data transfer that occurs after the link is established does not generate a handshake link, and the overhead of this part is saved, so that the performance of requesting uplink and downlink data can be effectively improved.

3) Network congestion is alleviated. Because only a few links remain at the same time.

Keepalive_timeout 100;

MySQL optimization

Mainly considering the storage engine aspect, the storage engine, also known as the table type, is the core part of MySQL and is responsible for handling the operations of the table. MySQL provides multiple storage engines, the most used are MyISAM and InnoDB.

Both MyISAM and InnoDB have their own advantages and disadvantages. MySQL has used InnoDB as the default storage engine since version 5.5. Does this mean that InnoDB is better than MyISAM? In fact, otherwise, the industry has specialized.

Let's take a look at the advantages of MyISAM:

1) MyISAM is designed for speed and works better with SELECT.

2) If the data of the table is static, that is, the data in the table is not frequently updated/deleted, most of them are just query operations, then using MyISAM is the best choice.

Let's go back and look at the scenario where WordPress uses the database: mainly to write blog posts to netizens to see, open a blog post corresponding database query operation. Then MyISAM is born for WordPress, and InnoDB is designed for high reliability and high write performance, and has little to do with WordPress blog.

And there is a little MyISAM backup database, it is very convenient to restore the database, or restore a single data table, directly operate the file .MYD file. Another point is that MyISAM is lightweight because it has fewer functions, so it saves system resources than InnoDB.

Modify the default storage engine to MyISAM, write it in my.cnf

Default-storage-engine = MyISAM # is to set the default storage engine key_buffer_size = 256M #MySQL5.7 which is only 8M by default, too small query_cache_type = 1 #Query cache cache query_cache_size = 256MB #Memory size allocated to the query cache query_cache_limit = 2MB # If the volume of the query cache result is greater than 2MB, it will not be cached.

The above settings can be viewed through the following MySQL statement:

Show variables like 'default_storage_engine%';show variables like 'key_buffer_size%';show variables like 'query_cache_%';

PHP optimization

PHP7's performance improvement over PHP5 can be more than one and a half points, so upgrade to 7 first, OpCache adds a lot to PHP performance, but found that many whites are installed OpCache but not enabled, they think that in the configure time On the --enable-opcache on the line. Copy the following content directly in the terminal.

Cat >> /usr/local/php/etc/php.ini<

It is the recommended value for high performance provided by PHP official. It is worth noting that the path behind zend_extension is best to write an absolute path, and the relative path seems to have a problem. After modifying php.ini, you must restart php-fpm to take effect.

Bathroom Accessories

Dongguan Metalwork Technology Co., LTD. , https://www.dgdiecastpro.com

This entry was posted in on