logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Help needed to determine the RAM usage of Apache
Author
Rasheed



Joined: 07 Jan 2014
Posts: 5
Location: India,Chennai

PostPosted: Wed 08 Jan '14 6:05    Post subject: Help needed to determine the RAM usage of Apache Reply with quote

Hello,

Firt of all i am sorry if my subject is not having enough info. Secondly i am sorry again to ask a basic question. But could anyone please help me regarding the below.

We are having a server with 4GB RAM which is used by 3 webserver instance.
Customer requsted us to add 10 more web instance in this server.
I am not sure whether any problem will occur if this server is loaded with 13 instances. Example RAM shortage etc.
Could anyone please tell me what are all i need to check to confirm that this server is capable for adding 10 more instances.

below are few Informations

[root@ogw01601 cgi-bin]# free -m
total used free shared buffers cached
Mem: 3823 3492 330 0 268 2417
-/+ buffers/cache: 807 3016
Swap: 5122 0 5122

This extra 10 instances will be same like the old 3 instances. So I hope by knowing the RAM consumption of the current running instance we can conclude whether we can add 10 more instances.

Setting in httpd.conf file:
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15
StartServers 4
MinSpareServers 4
MaxSpareServers 16
MaxClients 255

MaxRequestsPerChild 0

Memory usage of 1 web instaance:
[root@ogw01601 cgi-bin]# ps aux | grep 'bqk10' | grep 'httpd' | awk '{print $6}'
6224
5916
5964
5932
5952
5852
5912
5840
5816
5868
5844
5840
5900
5828
4356
8512
5956
5952
5880
6004
5940

Could anyone suggest me my server is capable of adding 10 more instances. And also please tell me how to find whether my server is capable of it.

Your help is highly appriciated.
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Wed 08 Jan '14 15:23    Post subject: Reply with quote

I would use htop to see the amount of used memory.
is there really a need for more instances? Can't you use vhosts?
Back to top
Rasheed



Joined: 07 Jan 2014
Posts: 5
Location: India,Chennai

PostPosted: Thu 09 Jan '14 4:39    Post subject: Reply with quote

Sorry htop wont recognize in our server. Its customer production server.

Here the customer requested for new web servers only.
They dont want vhost configration.

If i can able to find approximate memory usage of 1 old instance which is already present in the server , then its possible to see whether my server can hold new more 10 instances.

I checked the old 3 instances. All this 3 instance having maximum 21 child process at a time. I didnt see anytime more that that.
If 21 child proccess denotes lesser than or equal to 21 simultaneous request then i can do the below cacluation

each child process using around 5MB memory according to the above ps command. Since the old apache using a maximum of 21 child process then 21*5=105MB.
So 1 insance using 105MB.
Then 13 instances will use 1365MB. This server is dedicated for apache istance with 4GB RAM. Which means this server is good to hold 13 apache instance.

Does my above caclutaion method will give approximately correct answer?.
The method which i used to find single instance memory usage as 105MB is correct then i'll say to the customer how much maximum apache instance can this server withstand.
Even this 105MB is approximate value also its fine for me

Does the memory usage of a single instance depends major on the maxclient value ?
If it is , then i'll ask the customer the user count and if the customer says maximum 50 user will access at a time then i'll set maxclient value as 50 and will assume that 1 web apache instance will maximum uses 50*5MB of memory from RAM.

your reply for my above 2 questions will be more helpful to me
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 09 Jan '14 12:09    Post subject: Reply with quote

Rasheed wrote:

If 21 child proccess denotes lesser than or equal to 21 simultaneous request then i can do the below cacluation

each child process using around 5MB memory according to the above ps command. Since the old apache using a maximum of 21 child process then 21*5=105MB.
So 1 insance using 105MB.
Then 13 instances will use 1365MB. This server is dedicated for apache istance with 4GB RAM. Which means this server is good to hold 13 apache instance.

Does my above caclutaion method will give approximately correct answer?.


I guess so.

Rasheed wrote:

The method which i used to find single instance memory usage as 105MB is correct then i'll say to the customer how much maximum apache instance can this server withstand.
Even this 105MB is approximate value also its fine for me

Does the memory usage of a single instance depends major on the maxclient value ?


Yepp it does unless you run a script that call a background process with an insane usage.

Rasheed wrote:

If it is , then i'll ask the customer the user count and if the customer says maximum 50 user will access at a time then i'll set maxclient value as 50 and will assume that 1 web apache instance will maximum uses 50*5MB of memory from RAM.


Well I think so.

Rasheed wrote:

your reply for my above 2 questions will be more helpful to me




You also have to make sure to have a good connection to the internet / network. Means 1 gbit NIC, gbit switch and good connection to the net. I had it a few times when that was the bottleneck.


A recommendation is to use event mpm if you use apache 2.4 or worker mpm if you have to use 2.2
The threading will also save some memory.
Back to top
gggeek



Joined: 13 Feb 2013
Posts: 10

PostPosted: Fri 10 Jan '14 17:15    Post subject: Reply with quote

A few random notes on RAM (and CPU) usage for Apache:

- your method for finding out how many concurrent apache processes the server is able to run efficiently is basically correct. Just take care that linux itself (os + disk buffer/cache) should be left some ram to work, so out of 4GB, you should only allocate 3 to 3.5 GB to apache

- it is generally considered good practice to set maxclients so that the server does not start swapping, even when there is a lot of traffic coming in. http requests are served faster, even if they queue up, by a non-overloaded server. Also your db will be happier Smile

- concurrent http requests != concurrent users (important when talking to customer). To increase traffic served, being fast in answering http requests is vital (i.e. good php code). Also setting up in apache conf caching http headers and http compression helps a lot, freeing up apache process time to serve php pages instead of static files

- ram used per-http-request varies a lot. It is better to measure it after a while from server start (iirc Apache processes do not deallocate ram used between successive http requests). Also, if your app runs long-running/batch tasks, it is better to execute them via command-line php and not via http requests

- by using maxrequestsperchild > 0, you can set up Apache to kill somewhat frequently the child processes. This is a good way to avoid memory leaks and other excessive RAM usage. Still, Apache processes should not be recycled more often than once every few minutes

- best way to find out server load is by doing some load testing, using apachebench, jmeter or such programs. Note that using AB a normal php app will result to be cpu-bound (best throughput usually gotten at same nr. of concurrent clients as cpus available), and ram considerations might seem moot. Using jmeter to simulate real-life users, you will find different bottlenecks

- a keepalive of 15 secs is quite high - it keeps apache processes busy waiting for an http request which might not come in. The keepalive time should roughly be as long a the time used by the browser to download a single webpage (including all assets) - 3 to 5 secs is a general good idea
Back to top
Rasheed



Joined: 07 Jan 2014
Posts: 5
Location: India,Chennai

PostPosted: Wed 15 Jan '14 4:09    Post subject: Reply with quote

Thank you James Blond and gggeek for valuable information.

I understood concurrent http requests != concurrent users
Since the new web instance will do the same funcitionality as the old instance, roughly the new instances will aslo maximum uses around 25 child process as like the onld web instances. That means 25 concurrent http requests.
I'll talk to the customer by mentioning the concurrent http requests rather than concurrent users.

And MaxClient we set 255 always eventhough there wont be that much concurrent http request.

Once again thank you four you help Smile
Have a great day
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Mon 03 Feb '14 13:00    Post subject: Reply with quote

I tried this tool http://check-httpd-limits.googlecode.com/svn/trunk and I like it a lot.

sudo ./check_httpd_limits.pl --exe=/opt/apache2/bin/httpd
Back to top


Reply to topic   Topic: Help needed to determine the RAM usage of Apache View previous topic :: View next topic
Post new topic   Forum Index -> Apache