Search code examples
phpmysqllinuxperformancelamp

How to get a rough estimate of LAMP application capacity?


I have a LAMP application running fine, however the number of users are increasing each day. I don't want to be hit with a surprise one morning and find that everything broke because of overload. Is there a way to get a rough estimate of what capacity of the LAMP it is at?

I know that a full detailed report is many books worth of study but can I get some quick litmus test to see if things are running fine.

So say for the mysql component, how can I tell how much more load can it take? Is it at 30% capacity, 50%? etc.

Same for my apache. Although I have a feeling the DB will die before apache.


Perhaps my original was not too good, as English is not my native language. What I am really asking is a way to measure the current load. And then have a way to estimate based on the that load, how much further can I go before it fails. (And this should be done seperately for each component, mysqld, httpd)


Solution

  • For the current load, there are a couple things your can do. The most expensive, yet most detailed answers will be provided through a enterprise application such as "Gomez".

    However, if you're looking to do this yourself, see my previous answers below or use shell utilities such as: htop, top, w, and utilize Apache server-status

    Previous answers before question revision:

    What you are asking for is sometimes called application profiling.

    You need to create a rough memory formula like:

    httpd ram + php memory usage + mysql process usage = total request memory footprint

    You will also need a CPU formula, but you can also eyeball top during a load test.

    Apache has the command 'ab'.

    "ab is a tool for benchmarking your Apache Hypertext Transfer Protocol (HTTP) server. It is designed to give you an impression of how your current Apache installation performs. This especially shows you how many requests per second your Apache installation is capable of serving." http://httpd.apache.org/docs/2.0/programs/ab.html

    Here is a generic 'ab' benchmark command line:

    ab -n 10 -c 1 http://www.yoursite.com/
    # qty 10 total requests, 1 request at a time
    

    The strategy is to test the per process (user) load on your application from the web page request through completion. If you can identify how much ram Apache, PHP, and MySQL uses for each request, then you can quickly identify your system capacity.

    You'll probably have to use a mix of diagnostic tools like vmstat or top or iostat or ps, etc. to take a snapshot of what a number of requests will demand from your system.

    Finally, you are going to want to install Xdebug. This tool will help you profile the php side of the application. http://xdebug.org/

    Here is IBM's tutorial on installing Xdebug:

    http://www.ibm.com/developerworks/opensource/library/os-php-fastapps2/