Help required fine tunning apache

Hi,

I am using a 2GB Linode and I need some assistance in fine tunning the apache application. The server is installed with an open source CRM Application called CiviCRM and MySQL is installed on a different server.

This web application will be used by about 1000 users to to begin with and may scale depending on performance and usage.

Can anyone help me fine tune the apache application for this kind of requirement so that i can make best use of the hardware and application itself.

Thanks a lot.

Avinash

9 Replies

in file /etc/apache2/apache2.conf:

turn off KeepAlive:

KeepAlive Off

"prefork" is default variant, so find "IfModule mpmpreforkmodule" string and edit block:

 <ifmodule mpm_prefork_module="">StartServers          3
    MinSpareServers       3
    MaxSpareServers       5
    MaxClients           85
    MaxRequestsPerChild   4000</ifmodule> 

"MaxClients 85" - assuming each PHP process takes ~20M of memory, 85 * 20M = 1700M (so you will have (2048M - 1700M) free memory for cachers, as minimum).

For PHP: install APC.

If you can find good instruction - install nginx in front of apache.

Dear OZ,

Thanks so much.

Few clarifications. If I am understanding correctly, does MaxClients value indicate the number of concurrent users using the web service?

This is the prefork module in my httpd.conf. I didn't find apache2.conf file.

StartServers 8

MinSpareServers 5

MaxSpareServers 20

ServerLimit 256

MaxClients 256

MaxRequestsPerChild 4000

Also, you have mentioned you will have (2048M - 1700M) free memory for cachers, as minimum) how is this possible, cox, I have only 2GB RAM on my server.

What is APC?

Apologies for my very basic questions.

Avinash

@OZ:

in file /etc/apache2/apache2.conf:

turn off KeepAlive:

KeepAlive Off

"prefork" is default variant, so find "IfModule mpmpreforkmodule" string and edit block:

 <ifmodule mpm_prefork_module="">StartServers          3
    MinSpareServers       3
    MaxSpareServers       5
    MaxClients           85
    MaxRequestsPerChild   4000</ifmodule> 

"MaxClients 85" - assuming each PHP process takes ~20M of memory, 85 * 20M = 1700M (so you will have (2048M - 1700M) free memory for cachers, as minimum).

For PHP: install APC.

If you can find good instruction - install nginx in front of apache.

@Avinash.Rao:

This is the prefork module in my httpd.conf. I didn't find apache2.conf file.
I just don't know your OS. Anyway, params are identical in both files, so you can see which numbers you can change.

@Avinash.Rao:

Also, you have mentioned you will have (2048M - 1700M) free memory for cachers, as minimum) how is this possible, cox, I have only 2GB RAM on my server.
(2048M - 1700M) = 348M of memory. It was expanded just to illustrate.

@Avinash.Rao:

What is APC?
http://php.net/manual/en/book.apc.php

I am using CentOS 5.6 64-bit.

Thanks again.

@OZ:

@Avinash.Rao:

This is the prefork module in my httpd.conf. I didn't find apache2.conf file.
I just don't know your OS. Anyway, params are identical in both files, so you can see which numbers you can change.

@Avinash.Rao:

Also, you have mentioned you will have (2048M - 1700M) free memory for cachers, as minimum) how is this possible, cox, I have only 2GB RAM on my server.
(2048M - 1700M) = 348M of memory. It was expanded just to illustrate.

@Avinash.Rao:

What is APC?
http://php.net/manual/en/book.apc.php

Hi OZ,

I have studied the Apache Performance Tuning at http://httpd.apache.org/docs/2.2/misc/perf-tuning.html

I have a rough idea of how this works but am yet to understand it completely.

The application is open for about 10,000 users and I am expecting about 350 concurrent users when the application is released. How do i configure apache for this kind of a requirement. I have also upgraded the server to 4GB RAM.

Thanks.

@OZ:

in file /etc/apache2/apache2.conf:

turn off KeepAlive:

KeepAlive Off

"prefork" is default variant, so find "IfModule mpmpreforkmodule" string and edit block:

 <ifmodule mpm_prefork_module="">StartServers          3
    MinSpareServers       3
    MaxSpareServers       5
    MaxClients           85
    MaxRequestsPerChild   4000</ifmodule> 

"MaxClients 85" - assuming each PHP process takes ~20M of memory, 85 * 20M = 1700M (so you will have (2048M - 1700M) free memory for cachers, as minimum).

For PHP: install APC.

If you can find good instruction - install nginx in front of apache.

It depends on how you're running PHP. For example, if you're running PHP-FPM then configuring Apache is not really where you want to be looking because Apache isn't going to be handling the PHP processes.

Does this mean that, apache can be left with the default configuration and we need to fine tune PHP, considering how PHP is configured? I didn't see this mentioned in the Apache fine tuning website and hence the question.

@AlexC:

It depends on how you're running PHP. For example, if you're running PHP-FPM then configuring Apache is not really where you want to be looking because Apache isn't going to be handling the PHP processes.

If apache isn't handling PHP requests then it's memory usage will be considerably lower all it will be doing is handling static files (and in this case I'd switch to mpm-worker over prefork since it's threaded and will use less memory).

Maybe if you told us your setup then we'd be able to give better advise.

What apache MPM are you running?

(run apache2ctl -M | grep mpm to find out)

How are you running php? FPM/Fastcgi/Apache2/CGI(hopefully not)

Thanks for the response. I am awaiting response from my developer to provide details of PHP and i will post the details as soon as i receive them.

I couldn't find apache2ctl -M command, its apachectl (without the 2). First few lines of the output..

Loaded Modules:

core_module (static)

mpmpreforkmodule (static)

http_module (static)

so_module (static)

authbasicmodule (shared)

authdigestmodule (shared)

authnfilemodule (shared)

authnaliasmodule (shared)

authnanonmodule (shared)

authndbmmodule (shared)

authndefaultmodule (shared)

authzhostmodule (shared)

authzusermodule (shared)

@obs:

If apache isn't handling PHP requests then it's memory usage will be considerably lower all it will be doing is handling static files (and in this case I'd switch to mpm-worker over prefork since it's threaded and will use less memory).

Maybe if you told us your setup then we'd be able to give better advise.

What apache MPM are you running?

(run apache2ctl -M | grep mpm to find out)

How are you running php? FPM/Fastcgi/Apache2/CGI(hopefully not)

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