With the blowout development of cloud computing, the number of users of cloud servers has skyrocketed, and enterprise users and personal webmasters have become the first choice for cloud services. The use of pagoda panels to build cloud servers has made the operation and maintenance costs plummet. However, with the growth of website traffic, websites with high concurrency and large traffic will experience slow loading, freezes, and even the embarrassing situation of “the page cannot be displayed”. The rich buddies can choose to upgrade the high-configuration server, and the poor buddies can watch it, and Jun brother will take you to optimize it.
- Set Swap virtual memory for Linux system
Swap is the virtual memory of the Linux system. Customers accessing websites are actually executed through memory. Cloud servers have limited memory, and high-traffic access will cause insufficient memory. To solve this problem, when the physical memory is insufficient, the system will automatically call the hard disk as the memory to make up for the shortage of memory. This is the function of virtual memory. Most of the current cloud servers are based on kvm virtual architecture, and it is more necessary to turn on virtual memory (this function is not available for OVZ virtual architecture machines). Of course, if the children’s shoes are at the gangster level, there is no need to consider enabling swap if the memory is above 32G.
Opening method: Navigate to the left side of the pagoda panel and click [Software Management], then click the system tools at the top, find the Linux toolbox version 1.5 in the system tools list, click [Settings] on the far right, and then click the Linux toolbox window Click [Swap/Virtual Memory] on the left, fill in the Swap virtual memory size, and click [OK]. The pagoda official recommends that the swap capacity be about 1.5 times the real memory capacity. If your server’s memory is greater than 4GB, you can set a fixed value of 1-2GB.
A cloud server optimization tutorial built with pagoda panels, a high-concurrency and high-traffic website optimization solution, so that website access is smooth and not stuck
Two, add scheduled tasks to release memory
Releasing the memory is to release the data residing in the memory from the memory, improve the utilization of memory resources, and improve the performance of the cloud server. The Pagoda panel has considered the issue of memory release. You can add a memory release schedule task to release the server once a day or a week to release the memory usage of PHP, MYSQL, PURE-FTPD, APACHE, and NGINX. It is recommended to execute it at midnight every day at intervals. Determined according to the number of users on your website and the percentage of memory usage.
Release method: Log in to the pagoda panel and click [Scheduled Tasks] in the left navigation, select the task type to release memory, set the execution period and execution time according to your needs, and then click OK.
A cloud server optimization tutorial built with pagoda panels, a high-concurrency and high-traffic website optimization solution, so that website access is smooth and not stuck
Third, install the PHP cache extension
The pagoda panel integrates php 5.3 to php7.3 version, php 7.0 and above versions have been optimized a lot, processing speed is faster, more efficient and stable. Commonly used hph cache plug-ins are Opcache script cache, Memcached cache and redis content cache. We can improve the operating efficiency of the server by installing a cache plug-in. After the caching plug-in is installed, configure the cache for the corresponding website. Generally, configure it in the confing file of the site file to increase the speed of website access.
Script cache extensions such as opcache, xcache, apc, etc., please install only one of them, otherwise it may cause your site program to be abnormal. But we can install the two content caches Memcached and redis at the same time. We must also keep in mind that the more cache expansion is not the better, everything must have a degree, exceeding this degree, it will slow down the execution efficiency of PHP.
Installation method: Log in to the pagoda panel, click [Software Management] on the left navigation menu, find the php version you are using, click [Settings] on the right, enter the php management interface, and click [Install extensions on the left] on the php management interface ], select the cache you need to install.
A cloud server optimization tutorial built with pagoda panels, a high-concurrency and high-traffic website optimization solution, so that website access is smooth and not stuck
Fourth, php configuration optimization
Some websites or systems consume memory when running. Memory_limit is used to set the critical point of script memory. If the script memory reaches the critical point during running, an error will occur, but it does not mean that the larger the setting, the better. In principle The script memory setting should not exceed the physical memory of the cloud server, otherwise it may cause the disk swap to be enabled, the server resources will be exhausted, and the machine will eventually crash. Take wordpress, the world’s number one user, as an example. If you want to run smoothly, modify the memory limit of the memory_limit script to 256M, so that wordpress will be like a fish in water.
Configuration method: Log in to the pagoda panel, click [Software Management] on the left navigation menu, find the php version you are using, click [Settings] on the right, enter the php management interface, and click [Configuration modification on the left] on the php management interface ], modify the memory limit of the memory_limit script to 256M, and then save it.
A cloud server optimization tutorial built with pagoda panels, a high-concurrency and high-traffic website optimization solution, so that website access is smooth and not stuck
Five, PHP concurrency adjustment
Concurrency and daily visits are two concepts. The so-called concurrency can be simply understood as the number of customers visiting the website in the same second. Assuming that the concurrency is set to 50, you can have 3000 visits in 1 minute, and the daily visits are also very impressive. X, but it does not mean that the larger the concurrency setting, the better. If the concurrency setting is too large, the possibility of the server going down when the CC is attacked is also very high. Junge recommends that the concurrency setting should not exceed 300. The concurrency adjustment of php is a crucial part of optimization. The pagoda panel comes with several concurrency optimization solutions. Generally, for a cloud server with 1 core and 1G memory, you can set 30 concurrency or 50 concurrency.
Setting method: Log in to the pagoda panel, click [Software Management] on the left navigation menu, find the php version you are using, click [Settings] on the right, enter the php management interface, and click [Performance Adjustment on the left] on the php management interface ], select the concurrency scheme, and then save it.
A cloud server optimization tutorial built with pagoda panels, a high-concurrency and high-traffic website optimization solution, so that website access is smooth and not stuck
Six, MySQL performance optimization
The biggest server performance overhead is the database overhead. After the above optimizations, it is far from being able to withstand high-concurrency and large-traffic site visits. We need to optimize the performance of MySQL. The pagoda panel is very user-friendly, with a built-in database performance optimization program, we only need to click the mouse to complete. After performing one-key performance optimization, save and restart the database, then observe the current state, and make appropriate adjustments according to the recommendations.
Setting method: Log in to the pagoda panel, click [Software Management] on the left navigation menu, find the MySQL version you are using, click [Settings] on the right to enter the MySQL management interface, and click [Performance Adjustment on the left] on the MySQL management interface ], select the optimization scheme according to your server configuration, and then save it and then restart the database.
A cloud server optimization tutorial built with pagoda panels, a high-concurrency and high-traffic website optimization solution, so that website access is smooth and not stuck
Seven, Session storage settings
Session is called session information and is located on the web server. It is mainly responsible for the interaction between the visitor and the website. When a browser requests an http address, it will be passed to the web server and matched with the access information. The pagoda default session is saved in the designated In the folder, when the user accesses it, the Session ID must be retrieved from the file, which is not efficient. The pagoda panel can modify the Session storage location to redis to improve the efficiency of session information retrieval and reduce the response time.
Setting method:
First install the redis extension in the third step, then click [Software Management] on the left side of the pagoda panel, and then click [Run Environment] at the top to find the redis version, click [Settings] on the right to open the redis settings window, and then click redis On the left side of the window [Performance Adjustment], enter the password in the requirepass column. Set the password yourself. The more complex the better, copy the password you set after the setting is complete, and then click [Save].
A cloud server optimization tutorial built with pagoda panels, a high-concurrency and high-traffic website optimization solution, so that website access is smooth and not stuck
Then click [Software Management] on the left side of the pagoda panel, and then click [Run Environment] at the top to find the corresponding php version, click [Settings] on the right to open the php management window, and click [Session] on the left in the php management window Settings], then paste the password copied in the previous step in the password position, and then click Save.
A cloud server optimization tutorial built with pagoda panels, a high-concurrency and high-traffic website optimization solution, so that website access is smooth and not stuck
At this point, the PrestaShop performance optimization acceleration server article is over, so how to optimize the PrestaShop website? Please refer to: