How Strong your Server

These are the lill note for me and all of Sys.Administator. We’ll talk about how should we do with MySQL or APACHE Web Server on limited server.

MySQL
If we only have a 3GiB of memory then we want to used half of them. You should referred to these site : http://www.mysqlcalculator.com/ besides check your own mysql configuration with params : show variables; or show variables like “%params%”;
mysql_tunningAfter due consideration that max_connections could improve your concurrent user, innodb_log_buffer_size that can be reducing ‘i/o stat’ of server, innodb_buffer_pool_size related caches table and index data, etc.
Do not forget to change them permanently on my.cnf files or make it temporary with these params set global <name_of_params> = ‘value’;

Note : 8388608 => 8M; 1048576 => 1M; 2097144 => 2M; 16777216 => 16M

APACHE Web Server

Now we only have of half 3GiB from our remaining memory. So, how can we check it, how much apache consumed our memory. Try these script (Debian Environment):

ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}'

Output:
Apache Memory Usage (MB): 523.941
Average Proccess Size (MB): 18.7122

First of all, whenever an apache is started, it will start 2 child processes which is determined by StartServers parameter. Then each process will start 25 threads determined by ThreadsPerChild parameter so this means 2 process can service only 50 concurrent connections/clients i.e. 25×2=50. Now if more concurrent users comes, then another child process will start, that can service another 25 users. But how many child processes can be started is controlled by ServerLimit parameter, this means that in the configuration above, i can have 16 child processes in total, with each child process can handle 25 thread, in total handling 16×25=400 concurrent users. But if number defined in MaxClients is less which is 200 here, then this means that after 8 child processes, no extra process will start since we have defined an upper cap of MaxClients. This also means that if i set MaxClients to 1000, after 16 child processes and 400 connections, no extra process will start and we cannot service more than 400 concurrent clients even if we have increase the MaxClient parameter. In this case, we need to also increase ServerLimit to 1000/25 i.e. MaxClients/ThreadsPerChild=40

So this is the optmized configuration to server 1000 clients

# worker MPM
# StartServers: initial number of server processes to start
# MaxClients: maximum number of simultaneous client connections
# MinSpareThreads: minimum number of worker threads which are kept spare
# MaxSpareThreads: maximum number of worker threads which are kept spare
# ThreadsPerChild: constant number of worker threads in each server process
# MaxRequestsPerChild: maximum number of requests a server process serves
<IfModule mpm_worker_module>
    ServerLimit          40
    StartServers          2
    MaxClients          1000
    MinSpareThreads      25
    MaxSpareThreads      75 
    ThreadsPerChild      25
    MaxRequestsPerChild   0
</IfModule>

Second, how can we calculate the appropriate number to our server ??,
Please follow these links 😀 😀 😀 😀

These reference can be very useful:
http://www.genericarticles.com/mediawiki/index.php?title=How_to_optimize_apache_web_server_for_maximum_concurrent_connections_or_increase_max_clients_in_apache
http://stackoverflow.com/questions/25248184/memory-consumption-apache2-4

 

Cheers

Advertisements

Tinggalkan pesan atau komentar

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s