Memory Ram too high in HTTPD processes
You're using mod_php
, so Apache is also handling your PHP workloads at the same time. Since PHP needs lots of RAM (well, most like this do, including mod_perl
), you'll see higher RAM usage than serving just static files.
Related videos on Youtube
Comments
-
Cookboy almost 2 years
I management two dedicated servers. I use Centos 6 with Plesk Panel. Update: I use Apache with mod_php.
On the first server I have a site in Wordpress.
I have noticed that my httpd processes take up more memory each time. Besides the 'top' command, I use the following command to find out:
ps -ylC httpd --sort:rss
Image:
Pay attention to the RSS column. The httpd processes from 13MB to 127MB occupy in ram.
Installed apache modules are:
# Httpd l Compiled in modules: core.c prefork.c http_core.c mod_so.c
On the second server I have a website PHPBB.
In this case the involved processes like httpd. All occupy about 85MB.
Image:
I've read that should occupy 20MB. How I can profiling or optimize this? With what tool? Xhprof I tried, but it says that the memory used is less than that then use really ...
My memory are intensive in my servers. This is a big problem.
Update:
Server 1 Meminfo output:
#cat /proc/meminfo MemTotal: 5969120 kB MemFree: 625720 kB Buffers: 218424 kB Cached: 3289320 kB SwapCached: 61020 kB Active: 2832624 kB Inactive: 2066428 kB Active(anon): 1111532 kB Inactive(anon): 343184 kB Active(file): 1721092 kB Inactive(file): 1723244 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 1959920 kB SwapFree: 1789764 kB Dirty: 1044 kB Writeback: 0 kB AnonPages: 1348048 kB Mapped: 53712 kB Shmem: 63408 kB Slab: 379972 kB SReclaimable: 220388 kB SUnreclaim: 159584 kB KernelStack: 2064 kB PageTables: 28848 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 4944480 kB Committed_AS: 3148736 kB VmallocTotal: 34359738367 kB VmallocUsed: 24764 kB VmallocChunk: 34359713428 kB HardwareCorrupted: 0 kB AnonHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 6291456 kB DirectMap2M: 0 kB
Server 1 pmap of the httpd most memory processes (127mb and 118mb):
# pmap 11737 11737: /usr/sbin/httpd total 0K # pmap 12099 12099: /usr/sbin/httpd total 0K
Server 2 Meminfo output:
# cat /proc/meminfo MemTotal: 10088968 kB MemFree: 1773488 kB Buffers: 237064 kB Cached: 5752804 kB SwapCached: 38764 kB Active: 4516332 kB Inactive: 2738344 kB Active(anon): 1028388 kB Inactive(anon): 267156 kB Active(file): 3487944 kB Inactive(file): 2471188 kB Unevictable: 0 kB Mlocked: 0 kB SwapTotal: 1959920 kB SwapFree: 1883656 kB Dirty: 4444 kB Writeback: 0 kB AnonPages: 1226476 kB Mapped: 37020 kB Shmem: 30736 kB Slab: 862964 kB SReclaimable: 762056 kB SUnreclaim: 100908 kB KernelStack: 2424 kB PageTables: 57564 kB NFS_Unstable: 0 kB Bounce: 0 kB WritebackTmp: 0 kB CommitLimit: 7004404 kB Committed_AS: 2753212 kB VmallocTotal: 34359738367 kB VmallocUsed: 42048 kB VmallocChunk: 34359642628 kB HardwareCorrupted: 0 kB AnonHugePages: 0 kB HugePages_Total: 0 HugePages_Free: 0 HugePages_Rsvd: 0 HugePages_Surp: 0 Hugepagesize: 2048 kB DirectMap4k: 10485760 kB DirectMap2M: 0 kB
Server 2 httpd pmap:
# pmap 29772 29772: /usr/sbin/httpd total 0K
-
user almost 10 yearsHi Cookboy. You are asking quite a bit in this question, particularly in the paragraph that begins with "But this is not normal right?", and I imagine that is why it was downvoted. Consider editing your question to focus it on a single issue that can ideally be answered authoritatively within a few paragraphs. Also consider that the scope of this site is basically system administration in a professional context; if you are currently running a professional system where 100 MB of RAM matters that much, you should at least elaborate on why that is so, because to most that's margin of error.
-
Cookboy almost 10 yearsThank you so much. I will change my question, sorry for this, is my first question in ServerFault :) Thanks!
-
user almost 10 yearsWe all start out somewhere! Keep in mind the scope of each site (see the respective help center, particularly What topics can I ask about here? and What types of questions should I avoid asking?) and that the Q&A format works best when a single, authoritative answer is possible, and you'll likely do fine. If you are unsure, ask on the respective site's Meta site first (for example Meta Server Fault) whether a question on a given topic would be on topic on the site or not (but don't ask the actual question there).
-
Cookboy almost 10 yearsOK, I understand. I edited my question. It is right now? Thanks again!
-
Nathan C almost 10 yearsAre you using
mod_php
or fpm? That matters since if you're using the Apache module memory usage like this is normal for the PHP engine. -
Cookboy almost 10 yearsHello, phpinfo() tells me that I have loaded the module mod_php5. If I'm not mistaken this means I'm using mod_php, right? So this is normal behavior? Thanks you for your help.
-
Mircea Vutcovici almost 10 yearsI think you are not asking the right question. How did you determined that you have a memory usage problem? Could you add the output of
cat /proc/meminfo
? You can see how the virtual memory is mapped withpmap $PID
orcat /proc/$PID/maps
. Where $PID is the process ID that is using unexpected amounts of memory. -
Cookboy almost 10 yearsI edited the first post with the information you ask. I think I have a memory problem because my httpd processes use much more RAM than I think it should be used. I think they should use around 20mb. But in my case using 85MB or 120mb. Let me know if you can optimize memory usage of httpd processes and how. I had to buy memory and spend money, I prefer to optimize these processes if possible. Thank you very much.
-
-
Cookboy almost 10 yearsYes, I understand this. So this is not a problem? Is it normal to high memory usage of my httpd processes? So I just have to buy more RAM if I need it? Thanks!
-
Nathan C almost 10 years@Cookboy Yes, more RAM. You can also try switching to
php-fpm
instead, but this is beyond the scope of your question. With it though, you can finely tune FPM to use less memory at the expense of performance if you encounter high load. Similar can be done undermod_php
by limited the number of children HTTPD can spawn. -
Cookboy almost 10 yearsOK, but why do some processes use 13mb or 80mb and other 127MB? I do not understand. I need to know this information anyway. Is this related with the php client calls? How? Thanks again.
-
Nathan C almost 10 years@Cookboy It really depends. I'm not very familiar with the internal workings of
mod_php
, but I'm assuming it's based on how much processing it does and how much is cached data in PHP. Usually the parent Apache process recycles high-memory children on a regular basis.