Previous Next

Thread: IIS 6.0 FastCGI High CPU Usage

Last post 10-26-2007 10:55 AM by brashquido. 4 replies.

Average Rating Rate It (5)

RSS

Page 1 of 1 (5 items)

Sort Posts:

  • 10-18-2007, 8:57 PM

    • crazyweber
    • Not Ranked
    • Joined on 10-19-2007, 12:37 AM
    • Posts 1
    • crazyweber

    IIS 6.0 FastCGI High CPU Usage

    I have been stress testing the  fastcgi go live before I put it on my production server.  I am having an issue where fastcgi will run at 90-95% cpu usage.  I am using Exchange Performance and Stress to stress a vbulletin install.  My script for that is and running 50 instances:

    ADDHEADER host: forums.buddytv.com
    ADDHEADER Content-Length: 0

    GET /
    SLEEP 10
    GET /forumdisplay.php?f=172
    SLEEP 10
    GET /forumdisplay.php?f=84
    SLEEP 10
    GET /showthread.php?t=20662
    SLEEP 10
    GET /forumdisplay.php?f=84
    SLEEP 10
    GET /forumdisplay.php?f=23
    SLEEP 10
    GET /showthread.php?t=532
    SLEEP 10
    GET /showthread.php?t=532&page=2
    SLEEP 10
    GET /showthread.php?t=532&page=3
    SLEEP 10
    GET /forumdisplay.php?f=26
    SLEEP 10
    GET /showthread.php?t=63
    SLEEP 10
    GET /showthread.php?t=63&page=2
    SLEEP 10
    GET /
    SLEEP 10
    GET /
    SLEEP 10
    GET /
    SLEEP 10
    GET /
    SLEEP 10
    SKIP 2

    I am using Windows Small Business Server 2003 with php 5.2.4.  Does anyone know what could be the issue with this?

    System Specs:

    Intel Xeon 2.66Ghz

    1.00 GB
     

    Application Extension Mapping:

     C:\WINDOWS\system32\inetsrv\fcgiext.dll
     

    fcgiext.ini file: 

    php=PHP

    [PHP]
    ExePath=C:\Program Files\PHP\php-cgi.exe
    QueueLength=1000
    MaxInstances=4
    InstanceTimeout=30
    InstanceMaxRequests=200 

     If you need any more information just let me know. Thanks
     

  • 10-18-2007, 11:12 PM In reply to

    • rickjames
    • Top 25 Contributor
    • Joined on 10-31-2006, 6:43 PM
    • Posts 193
    • rickjames

    Re: IIS 6.0 FastCGI High CPU Usage

    Hi crazyweber,

    There are a zillion factors that influence performance, which makes general statements hard, cause they're only right 90% of the time. Generally I approach performance like this: set a goal, achieve it, move onto my next problem.

    Specific questions:

    - how many requests/sec does you site need?

    - how many are you currently achieving?

    - have you done similar sites before? was there their performance similar? if not, what sort of throughput do other people normally see with this application?

    On performance testing:

    - you're doing it! Which means you're already doing better than 90% of web site owners out there :-)

    - there are many resource bottlenecks possible. In testing I try to get the CPU maxed out. If I can't max the CPU out I figure out why (disk, ram, bandwidth, other..). Then, assuming throwing more hardware at the problem is not more cost-effective, I start analyzing the CPU usage. Which process(es) are consuming all the CPU. Does it make sense that they are? Could they be split onto seperate machines? (e.g. DB). Eventually one process will come into my sites (pun intended :-)).

    - Assuming you find php-cgi.exe is eating all your CPU: Start looking into PHP performance tricks. Here are 16 PHP performance talks by some smart folks: http://talks.php.net/index.php/Performance

    Finally I can't avoid a plug :-) : IIS 7 contains a new module, called "output caching", for certain type of anonymous, dynamically generated, effectively static pages, it gives a massive performance boost. (I get thousands of requests/sec on my ancient laptop)

    Cheerz,

    Rick

  • 10-25-2007, 9:16 AM In reply to

    • brashquido
    • Top 25 Contributor
    • Joined on 05-21-2006, 8:31 PM
    • Australia
    • Posts 153
    • brashquido

    Re: IIS 6.0 FastCGI High CPU Usage

    Hi Crazyweber,

    Just backing up what Rick has said. Vbulletin is a PHP application that backs onto a MySQL database, so you may find that PHP is waiting for MySQL to retrieve data. I've recently written an article called Performance tuning PHP 5.2 on IIS which might be of some interest to you. Here are some general tips I would recommend you look at for improving the performance of your PHP/MySQL environment.

    PHP:

    • Increase MaxInstances if possible, as 4 instances are always going to struggle serving 50 simulated users.
    • Look into utilizing a bytecode/opcode cache
    • Ensure php.ini is tweaked for performance (output buffering on, minimal logging, don't load extensions that are not required, etc)
    • Use Xdebug to trace time/resource expensive code

    MySQL

    • Enable slow query log to get an idea of what queries are time/resource expensive
    • Enable logging of queries not using indexes as they also lead to poor performance
    • Select database engine that suits your needs best. For example MyISAM is fast for reads, but InnoDB is better for heavy write activity (such as forums) as it supports row level locking.
    • Check your Table_locks_waited value as if this is high it usually indicates a performance issue with MySQL.
    • Look into enabling MySQL query cache to reduce load. Be aware though that the MySQL query cache is byte exact, so for example a query such as "SELECT user FROM mysql.user;" is not the same as "select user from mysql.user;" as far as the query cache is concerned. If you enable the query cache monitor the hit rate closely as if the hit rate is too low it will actually harm performance.
    • Tweak the other various caches and buffers in MySQL.
    • Use Memcache to lower your MySQL load

     

    ----------------
    Dominic Ryan
    Microsoft IIS MVP
    www.iis-aid.com
    My IIS articles
    My PHP articles
    My How-to guides
  • 10-25-2007, 12:37 PM In reply to

    • rickjames
    • Top 25 Contributor
    • Joined on 10-31-2006, 6:43 PM
    • Posts 193
    • rickjames

    Re: IIS 6.0 FastCGI High CPU Usage

    Hi Dominic,

    I enjoy reading your blog at iis-aid.com, thanks for all the excellent articles!

    I'm curious about your maxInstances suggestion. Was that using TP2 or GoLive? IIS 6 or IIS 7? In TP2/Beta3, the FastCGI process was tied to a request until the client said it had received the last byte. In IIS 6 GoLive / IIS 7 RC, I added additional buffering (6:ResponseBufferLimit, 7:system.webServer/handlers/add@responseBufferLimit).

    If the FastCGI response size < this, then the FastCGI process can start processing the next request before the client even sees the first response byte. Theoretically drastically reducing the number of CPU-bound FastCGI applications needed to keep clients busy. (In theory, for a CPU-bound PHP app, you only need maxInstances=number of processors, to achieve max throughput). Using GoLive/RC, do you see maxInstances exceeding numcpus helping increase throughput?

    Cheerz,

    Rick.

     

  • 10-26-2007, 10:55 AM In reply to

    • brashquido
    • Top 25 Contributor
    • Joined on 05-21-2006, 8:31 PM
    • Australia
    • Posts 153
    • brashquido

    Re: IIS 6.0 FastCGI High CPU Usage

    Hi Rick,

    Interesting! I must have overlooked the ResponseBufferLimit setting with the Go Live release. I've just done some more testing using the same setup as described in my article above, but this time I just used FastCGI with thread safe PHP 5.2.4 and eAccelerator 0.9.5.2 and changed the MaxInstances value to 1, 2, 4, 8, 12, 16, 20 & 24 for each test.

    The results support what you've said, in that once I got beyond a value of 2 for MaxInstances (which matches the number of CPU's in my test system) there was no throughput increase. In fact if anything throughput decreased slightly as the MaxInstances got above 2, but not by enough to draw any real conclusions from other than there is no performance gain to be had by increasing MaxInstances beyond the number of CPU's in your system unless the FastCGI response is larger than the ResponseBufferLimit. You could then increase either the ResponseBufferLimit or the MaxInstances value from here to increase throughput.

    I've been using the community version of FastCGI for around 3~4 years, and increasing the instances with this version definitely gains performance. I usually found that the sweet spot was between 8 and 16 instances depending on the server specs. I'd say that the PHP processes launched by the community version of FastCGI are also tied to a request until the client has received all the data like the TP releases, which is why it made sense to increase the number of instances to boost throughput. Very interesting.



     

    ----------------
    Dominic Ryan
    Microsoft IIS MVP
    www.iis-aid.com
    My IIS articles
    My PHP articles
    My How-to guides
Page 1 of 1 (5 items)
Page view counter