Peak and OOMing

Hello guys,

I have problem with some peaks on my linode. Support says server is OOMing. Ok so i need to determin what is using my memory. Lets say i do that with

ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | less

and i get some info, lets say i see apache is using a lot of small fragments and i have 30 of lines like these

2.7 3.6 28124 50700 /usr/sbin/apache2 -k start

how do i determin and go from here to see what is starting apache and using resources? Or to be exact, which web page as i have 10 drupal pages on my server and some of them are taking too much resources. How to get to that information so i can optimize my sites and see which one to optimize?

13 Replies

Two phrases: reduce MaxClients, disable KeepAlive.

The relevant configuration files can be found in /etc/apache2 for Debian and Ubuntu, and /etc/httpd in CentOS.

I'll try that. But i would also like to know how to do what i asked. Determine what site on my VPS run which process?

If you're using mpm-prefork (which you are, if you're using mod_php), all Apache processes are equally likely to handle any request for any site. The connection is assigned to a process before the HTTP request is received from the client. -rt

mod_status will probably give you an idea of which virtual-host is the busiest, etc.

Apachetop seems to be what i am looking for but after i installed it i only get zero values and not like its seen in this image

http://freshmeat.net/screenshots/36/05/ … 1237052455">http://freshmeat.net/screenshots/36/05/360532c2afdc0c48f7cc866132afcbc2_medium.png?1237052455

Azathoth have you some idea what i need to configure for this to work?

this is what i have :-(

last hit: 00:00:00 atop runtime: 0 days, 00:00:05 15:48:13

All: 0 reqs ( 0.0/sec) 0.0B ( 0.0B/sec) 0.0B/req

2xx: 0 ( 0.0%) 3xx: 0 ( 0.0%) 4xx: 0 ( 0.0%) 5xx: 0 ( 0.0%)

R ( 5s): 0 reqs ( 0.0/sec) 0.0B ( 0.0B/sec) 0.0B/req

2xx: 0 ( 0.0%) 3xx: 0 ( 0.0%) 4xx: 0 ( 0.0%) 5xx: 0 ( 0.0%)

````
apachetop -f /path/to/your/access.log

Also:

man apachetop
````

And hit ? when in apachetop to see options.

Keep in mind you'd need a common log file for all the vhosts on the server. My own common log file writes hostname instead of remote IP as first field, so that I can make nice webalizer stats and use the Remote section to see most active domains.

Stll have problems :-)

Tried it with apachetop -f /var/logs/apache2/access.log

but still zeroes. Is it this apache2/access.log I am supposed to use? or some other? as this one is empty file (checked it)?

Where are your access logs? Assuming each of your vhosts have separate access log, you have to configure them to also post to a common log.

If your (default) /var/logs/apache2/access.log is empty, you either do not have access logging set up, or individual vhosts are logging elsewhere.

For apachetop to work as intended here you need a common log where ALL your vhosts will post.

I made a setup as on linode help pages and each site has a

ServerAdmin webmaster@example.org

ServerName example.org

ServerAlias www.example.org

DocumentRoot /srv/www/example.org/public_html/

ErrorLog /srv/www/example.org/logs/error.log

CustomLog /srv/www/example.org/logs/access.log combined

so this is where log of each site is. But then i will have just one site and its logs and i need to have concurent sites to display their usage so there is none use to see log file of one.

Ok how do i setup then apache log file or where do i check current setup and make a common log file?

@marko_roi:

so this is where log of each site is. But then i will have just one site and its logs and i need to have concurent sites to display their usage so there is none use to see log file of one.

A vhost can log to more than one log at once, just add another CustomLog directive pointing to – for example /srv/www/common.log -- for all your vhosts, ASIDE to their default logs. Then point apachetop -f to that common log.

https://httpd.apache.org/docs/2.0/logs.html#accesslog

How to limit log file sizes? Or make them truncate? I had some larger than 1 GB. What is the best practice?

apt-get install logrotate

That will automatically set up rotation for most system logs under /var/log, and you can add rules for other logs in other places in /etc/logrotate.d/. This (along with etckeeper and sl) is on my essential operational maintenance tools list.

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct