In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you how php solves too many problems in the process, I believe most people don't know much about it, so share this article for your reference. I hope you can learn a lot after reading this article. Let's learn about it together.
Php process too many solutions: 1, through the "ps-ef | wc-l" command to view the current system processes; 2, and then use the relevant commands to view the largest memory-consuming processes; 3, query php-fpm processes; 4, kill processes or limit the size of memory.
This article operating environment: linux5.9.8 system, PHP5.5 version, DELL G3 computer
Too many php-fpm processes on the linux server cause memory to fill up processing:
When I arrived at work in the morning, I found that the server mysql server stopped and got up.
The query log shows that the memory is full. Kill the mysql service. Kill the linux server. If the memory is full, the automatic cleaning process will prevent the server from hanging up. If you choose, whoever occupies the large memory will kill first. I have the largest memory occupied by the mysql service in my server, so kill mysql.
Then restart mysql query memory
Here, tell me what you think of linux's memory.
For instance
The following shows that free is showing the current memory usage, and-m means M bytes to display the content. Let's have a look together.
$free-mtotal used free shared buffers cachedMem: 1002M 769M 232M 0M 62M 421M 715MSwap + buffers/cache: 286m 715MSwap: 1153M 0M 1153M ML-Real memory usage = used-buffers-cached = 286m-
The first part is the Mem line:
Total total memory: number of memory used by 1002Mused: number of free memory in 769Mfree: 232Mshared is currently out of use, always 0buffers Buffer cache memory: 62Mcached Page cache memory: 421m
Relation: total (1002m) = used (769m) + free (232m)
The second part (- / + buffers/cache):
(- buffers/cache) used memory: 286m (refers to used-buffers-cached in the first part Mem line) (+ buffers/cache) free memory number: 715m (refers to free + buffers + cached in the first part Mem line)
Visible-buffers/cache reflects the memory actually eaten by the program, while + buffers/cache reflects the total amount of memory that can be misappropriated.
The third part refers to the exchange partition, I think we all understand.
I think everyone is still dizzy when they look up there. The results of the first part (Mem) and the second part (- / + buffers/cache) deal with why used and free are so strange.
In fact, we can explain it from two aspects.
For the operating system, it is a parameter of Mem. Buffers / cached are used, so it thinks that free is only 232. 0.
For applications, (- / + buffers/cach). Buffers/cached is equally available because buffer/cached is designed to improve the performance of program execution, and buffer/cached is quickly used when the program uses memory.
Therefore, to look at the application, to (- / + buffers/cache) free and used-based. So let's just look at this. In addition to tell you some common sense. Linux in order to improve disk and memory access efficiency, Linux has done a lot of careful design, in addition to caching dentry (for VFS to accelerate file path name to inode conversion), but also adopted two main Cache methods: Buffer Cache and Page Cache. The former is for the read and write of disk blocks, and the latter is for the read and write of file inode. These Cache can effectively shorten the time of system calls (such as read,write,getdents).
Remember that memory is for use, not for viewing. Unlike windows, no matter how much your real physical memory is, he has to swap files with his hard drive to read. This is why windows often prompts that virtual space is insufficient. Think about it, how boring, when there is still most of the memory, set aside some of the hard disk space to act as memory. How can hard disk be faster than memory? So when we look at linux, as long as we don't use the swap space of swap, we don't have to worry about having too little memory. If you often use a lot of swap, you may want to consider adding physical memory. This is also the standard for linux to see if the memory is enough.
-
Put him through.
It is found that the server has only 1.9 gigabytes of memory left, and then check it with the top command.
The first top is the current time; the number of days the system is running; the number of users; the average system load. The last three values are the average number of processes 1 minute ago, 5 minutes ago, and 15 minutes ago, respectively. When this value exceeds the number of CPU, the load is too high.
The second line Tasks is: total number of processes; number of running processes; number of sleep processes; number of processes stopped; number of processes restored
The third line CPU (s) is:
Percentage of us:user user space occupied by cpu
Percentage of sy:system kernel space occupied by cpu
Ni:niced percentage of cpu occupied by processes that have changed priority
Percentage of idle cpu
Percentage of cpu occupied by wa:IO wait IO waiting
Percentage of cpu occupied by hi:Hardware IRQ hard interrupts
Percentage of cpu occupied by si:software soft interrupt
St: time stolen by hypervisor
The fourth line of Mem is: total memory; used memory; free memory; buffer in use memory
Line 5 (Swap): similar to the fourth line, but reflects the use of the swap partition (Swap). Swap partitions (Swap) are frequently used and can be seen as the result of insufficient physical memory
The top of the top output interface also shows the overall memory usage of the system. These data are similar to free, so I won't repeat them. Let's move on to the following columns of memory-related data, such as VIRT, RES, SHR, and% MEM.
These data contain some of the most important memory usage of the process, which we will look at one by one.
VIRT is the size of the process's virtual memory, which is counted as long as it is the memory requested by the process, even if the physical memory has not been actually allocated.
RES is the amount of resident memory, which is the physical memory actually used by the process, but does not include Swap and shared memory.
SHR is the size of shared memory, such as shared memory used with other processes, loaded dynamic link libraries, and code snippets of the program.
% MEM is the percentage of the physical memory used by the process as the total memory of the system.
In addition to knowing the basics, there are two things you should pay attention to when looking at the top output.
First, virtual memory usually does not allocate all physical memory. From the output above, you can see that the virtual memory of each process is much larger than the resident memory.
Second, shared memory SHR is not necessarily shared. For example, program code snippets and non-shared dynamic link libraries are also included in SHR. Of course, SHR also includes memory that is really shared between processes. So when calculating the memory usage of multiple processes, do not directly add up the SHR of all processes to get the result.
Just look at it this way or it doesn't feel like it should take up a lot of memory, and then use the command to see how many processes there are on the current system.
Ps-ef | wc-l
Then use the command to view the 500 processes that take up the most memory:
Ps-aux | sort-k4nr | head-n 500
The process of intercepting part of the PHP accounts for 200. each has more than 100 megabytes.
Explain the meaning.
USER: itinerary owner PID: pid%CPU: occupied CPU utilization% MEM: occupied memory utilization VSZ: occupied virtual memory size RSS: occupied memory size TTY: terminal secondary device number (minor device number of tty) STAT: the state of the journey, the linux process has five states: d uninterruptible sleep state (usually IO process) R is running but traversable in queue; S is dormant; T stops or is tracked; W enters memory swap (invalid since kernel 2.6); X dead process (rarely seen); Z zombie process; < higher priority process N lower priority process L some pages are locked in memory; leader of the s process (there are child processes under it) Multiprocess (using CLONE_THREAD, similar to NPTL pthreads); + process group located in the background; Note: other states include W (no resident page)
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.