Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to optimize the use of small memory VPS

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

This article focuses on "how to optimize the use of small memory VPS", interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let the editor take you to learn "how to make the use of small memory VPS more optimized"!

First taste

I've liked this since I started experimenting with VPS at the beginning of this year. In the VPS twists and turns on the road to use a lot of VPS providers, basically 256m memory VPS (because the price of this memory is more suitable for me, no matter how high memory will feel wasted), there are OpenVZ, Xen, Kvm.

Initially in the use of PhotonVPS, lightwave Xen VPS, after testing, I chose lightwave, because I do not know whether it is my RPWT or some reason, PhotonVPS in my hand will hang up for no reason.

After using lightwave for a period of time, the line was occasionally drawn, and I tried a few more VPS (there was a disaster that made me suffer from data loss: fortunately, there was a backup). Later, I bought a Linode 512, but it took half a month to withdraw. Although it was used by three friends, I still felt that the price was too high and wasteful.

And then moved back to lightwave. Unfortunately, it is still a problem with the line (it was later judged that the line was occasionally drawn + the environment configuration of my website was not good enough), and the sharing of several good friends was disbanded. Of course, I also feel tired.

Advanced level

Around mid-March, I found ramhost and waited to buy a trial of OpenVZ VPS with 128m memory, and planned to post only my own blog. At that time, I knew a little bit about the configuration of the website environment of VPS, and I also gave up the domestic one-click package and tried the foreign one-click package, and the result was very good. After putting it for a period of time, two friends joined, 128m put three blogs, ramhost vps is very stable, will not hang up inexplicably, occasionally 502 because my memory is too small. About two or three months later, I joined another friend, and then I sent ticket to ramhost customer service asking for 256m of memory. The host has been running steadily until September, during which there was no restart except for one server upgrade.

In September, I entered the second VPS of ramhost, VPS based on KVM, and just bought the cup set: ramhost's own customer database was damaged due to hardware problems in the computer room, and it took about 3 weeks to recover, during which VPS began to be unstable, because the background hung up, so VPS could not send ticket after hanging up, so I could only contact customer service by email to help restart. After 36 hours of email, there was no reply to help restart! Gradually I was also disappointed with ramhost's vps. But the 256m vps is paid quarterly, so I gritted my teeth and persisted for almost 2 months. During this period, another DDOS event occurred on the server, and sometimes there was no response (similar to hanging up) on the two VPS. All kinds of depression, two VPS moved to each other n times ~ embarrassed rz

By the end of October, I finally couldn't stand it. Ramhost's kvm and openVZ's vps still had a month, and now the performance is that openVZ is relatively stable. So I decided to find another VPS, after more than 10 days of selection-in fact, do not trust those VPS recommendation sites, the water is too deep! Later, on the recommendation of a friend, I found and bought Hostigation's kvm-based 128m vps (which took me several days to buy, because Hostigation and ramhost are not in stock every day), and the next day I sent ticket to 256m. Now it has been running steadily for half a month, and the speed is very stable every day. I hope it can be maintained.

After so many twists and turns (installation environment, move countless times), my summary is (not necessarily correct, can only refer to): 256m VPS had better put 3 WordPress blogs (each blog day PV is less than 1800), although you can put 4 or even 5, but the performance is from time to time card, from time to time 502 504 to show you. Maybe it has something to do with environment configuration technology, but it's the limit for me. (the more technical friend said that if it was set up, it would be no problem to put 8.)

At present, I like to manually configure the environment, no longer use one-click package, although one-button package is actually installed foolishly, but to achieve the effect, especially the small memory VPS, the parameters should be re-set according to their own VPS, so I might as well install the configuration manually.

Optimize the footprint of VPS memory using WDCP

These days, the installed wdcp memory occupancy has been high, a total of 1G of memory, the real occupation of only 60m available, according to the tutorial, adjusted, really decreased significantly, now put the tutorial here for their own reference for people in need.

First log in to SSH to see what takes up memory.

Use

The code is as follows:

Ps-aux

Command

Since I have adjusted it at the time of writing this article, I will not post the screenshot before the adjustment. In the actual view, we find that most of the memory-consuming programs are caused by httpd. In view of this phenomenon, let's optimize the apache configuration file httpd.conf.

For the VPS where wdcp is installed, the modified file is / www/wdlinux/httpd-2.2.22/conf/httpd-wdl.conf

The V3 version I installed is httpd-2.4.18.

Found in httpd-wdl.conf, this is the parameter segment of apache in prefork mode. Change the values of the paragraph to the following values:

The code is as follows:

ServerLimit 256

StartServers 2

MinSpareServers 2

MaxSpareServers 5

MaxClients 256

MaxRequestsPerChild 50

The most important memory-consuming parameters are the red ones. After the above settings, the number of httpd child processes is kept at a minimum of 2, and the extra processes automatically destroy the free memory after processing more than 50 requests (this value should not be set to 0, otherwise the http process will not be destroyed all the time), so as to ensure that the memory can be released in time under normal traffic. These values can be adjusted as needed to fit the memory size. Restart the apache service after modification will take effect.

The meaning of each field:

Maximum number of ServerLimit customers

Number of child processes established when the StartServers server starts

Minimum number of idle child processes in MinSpareServers

Maximum number of idle child processes in MaxSpareServers

MaxClients maximum number of client access requests at the same time

MaxRequestsPerChild maximum number of requests allowed for servo per child process during its lifetime

Adjusted, in the service restart, select web restart, the effect after restart is very obvious, directly fall to the real occupation of more than 200m, after a few days of use, has been between 350m and 400m.

At this point, I believe you have a deeper understanding of "how to optimize the use of small memory VPS". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report