Forum Moderators: phranque

Message Too Old, No Replies

How to determine the RAM usage of Apache web instance

Need to know whether my server box can withstand new instance creation

         

IamRasheed

9:46 am on Jan 8, 2014 (gmt 0)

10+ Year Member



Hello,

I am sorry for asking such a basic question. But could anyone please help me regarding the below.

We are having a Linux server with 4GB RAM which is used by 3 production Apache web 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. These instances will do the same function as 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

Here almost 20 child proccess is there in 1 of my web instance. Does it means currenlty there are 20 simultaneous connections present.
Each child process having around 5mb. We set maxclient values as 256 then if 255 request comes at a time then 256 child proces will be created each with 5MB?
I am asking this question because if my above understanding is correct then i will ask the customer about the maximum user count. With that i can calculate how much memory required for each instance.
Example if the customer tells maximum user will be 50 then ican conclude as maximum memory required for 1 instance will be 50*5. 50 is the user count and 5 is the memory consumed by each child proccess.

Could anyone suggest me on this.
I am sorry if the information i provided is insufficient.

Your help is highly appriciated.

graeme_p

10:17 am on Jan 8, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Example if the customer tells maximum user will be 50 then ican conclude as maximum memory required for 1 instance will be 50*5. 50 is the user count and 5 is the memory consumed by each child proccess.


ps greatly over estimates memory usage because it includes shared memory. You need to use something like smem

One other thing to consider is that less memory for buffers and cache may slow things down if you add enough processes.

These instances will do the same function as the old 3 instances.


Then why do you need multiple instances? The only use case I have come across for multiple instances on a single server is if different instances have different requirements (e.g. different modules installed).

IamRasheed

1:58 am on Jan 9, 2014 (gmt 0)

10+ Year Member



Thank you for your reply.
Could you please tell me how to calculate since my calculation is wrong. what i thought was if i can able to find my old instance using 100MB(Just an example) then the upcoming new instance also each will require 100MB.
If there is any calculation i can use to find it out.


////Then why do you need multiple instances? The only use case I have come across for multiple instances on a single server is if different instances have different requirements (e.g. different modules installed). ////

Sorry if my initial statement was not clear.
The new 10 instance also will do the same function but the website will be different.
Customer requires 10 apache webserver to host 10 website.

graeme_p

5:50 am on Jan 9, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



If you are using a recent Debian based distribution, you should have smem in the repos. Install and run it. The column headed USS will tell you how much memory a process is using that is not shared with other processes. This will be a better estimate, but is prone to underestimate - depending on whether instances have different modules installed etc.

Customer requires 10 apache webserver to host 10 website.


Why not virtual hosts?

IamRasheed

6:27 am on Jan 9, 2014 (gmt 0)

10+ Year Member



We are using Red Hat Enterprise Linux Server release 5.1 with Aapache 2.0.63.
And our environment, everything is fixed and having pre defined policy. We cannot change or add any tool.

And for virtual host also the same. Having fixed policies.
2 virtual hosts will be used for 80 and 443 port.
They are not ready to do any advanced configuration.
And not ready to use different websites in the same webserver using vhost.
Each website should work indipendantly. Each website is for each application. No application having inter connection. Since its the customer requirement , we need to follow it.

Why i specified that all the instance will do the same function is because just i want to let you know that all the instance will use same amount of memory which will help us easy to find out the memory requirement.
For example if the current instance 1 , 2 and 3 using 105MB each then the upcoming 10 instance also will use the same amount of memory.

Its fine for me if ps command will give more memory usage than its actual usage also. Lesser if it gives only problem because after we created the apache instance it will result is server down due to out of memory of physical server memory.

So can you please tell if
ps aux | grep 'bqk10' | grep 'httpd' | awk '{print $6}'

command gives output of 21 child proccess with 5mb each
then can we conclude that this particular web instance will use maximum 105MB not more than that as ps command always output over estimates memory usage.

Your reply regarding the above would be very helpful.

graeme_p

12:39 pm on Jan 9, 2014 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Assuming you are not swapping, the using the RSS number (which is what your command line is doing) is a fairly safe way of doing it for your purposes.

If you want more detail about how and why it works, google for "linux process memory usage" and there are a bunch of good guides.