Powered by WordPress | Theme by mg12 | Valid XHTML 1.1 and CSS 3
  • Apache/Wordpress Performance Tuning

    Yeah, it’s been a long time since I’ve written anything in this space. I did however recently move this site from the shared hosting provider I was using to a Ubuntu 8.04.2 LTS Xen instance. The plus of this is greater control. The downside is that I’m cheap, especially for a personal blog with no traffic, so we’re talking an instance with a whopping 256 MB of RAM here. So how to speed it up?

    The first thing I did was try to get a baseline using ApacheBench, which I ran after performing zero tuning. The result was utter disaster. Apache would spin off new processes until memory and CPU were completely consumed. System load spiked to over 40, and the benchmark failed to complete. Clearly the very first thing I needed to do was size Apache down for my limited system. So I made the following changes to apache2.conf: StartServers 1

        StartServers          1
        MinSpareServers       1
        MaxSpareServers      5
        MaxClients          5
        MaxRequestsPerChild   300

    Needless to say, that’s greatly reduced from the default. Obviously I can’t serve much traffic, but I hopefully won’t be allowing anyone to DoS my server. This time, ApacheBench completed fine:

    Server Software:        Apache/2.2.8
    Server Hostname:        platospharmacy.org
    Server Port:            80
    Document Path:          /
    Document Length:        54931 bytes
    Concurrency Level:      25
    Time taken for tests:   500.377 seconds
    Complete requests:      2212
    Failed requests:        240
    (Connect: 0, Receive: 0, Length: 240, Exceptions: 0)
    Write errors:           0
    Total transferred:      122194793 bytes
    HTML transferred:       121592041 bytes
    Requests per second:    4.42 [#/sec] (mean)
    Time per request:       5655.252 [ms] (mean)
    Time per request:       226.210 [ms] (mean, across all concurrent requests)
    Transfer rate:          238.48 [Kbytes/sec] received

    Connection Times (ms)
    min  mean[+/-sd] median   max
    Connect:       29   48 169.3     34    3049
    Processing:  1108 5564 2041.5   4791   27755
    Waiting:      845 5072 1812.4   4381   14593
    Total:       1140 5612 2056.2   4830   27789

    Obviously not amazing. I’m coming nowhere close to the potential of my uplink, I’m getting a pathetic amount of reqs/sec, and far too many failed requests. This needs to be improved. So I installed the WP SuperCache plugin and configured it for full cacheing:

    Server Software:        Apache/2.2.8
    Server Hostname:        platospharmacy.org
    Server Port:            80

    Document Path:          /
    Document Length:        54968 bytes

    Concurrency Level:      25
    Time taken for tests:   500.007 seconds
    Complete requests:      6850
    Failed requests:        6845
    (Connect: 0, Receive: 0, Length: 6845, Exceptions: 0)
    Write errors:           0
    Total transferred:      379514426 bytes
    HTML transferred:       376800780 bytes
    Requests per second:    13.70 [#/sec] (mean)
    Time per request:       1824.844 [ms] (mean)
    Time per request:       72.994 [ms] (mean, across all concurrent requests)
    Transfer rate:          741.23 [Kbytes/sec] received

    Connection Times (ms)
    min  mean[+/-sd] median   max
    Connect:       29   39  63.3     37    3055
    Processing:   869 1782 163.8   1748    3021
    Waiting:      684 1471 150.7   1436    2752
    Total:        908 1821 176.0   1786    5497

    This is clearly a big improvement in raw performance, but look at all those failed requests. This of course still is not going to cut it. The next step was to install Alternative PHP Cache. Signifigantly reducuing PHP compiles should show some big improvement. I went with APC over the alternatives because it’s due to be included by default in PHP 6.

    Server Software:        Apache/2.2.8
    Server Hostname:        platospharmacy.org
    Server Port:            80

    Document Path:          /
    Document Length:        56024 bytes

    Concurrency Level:      25
    Time taken for tests:   500.015 seconds
    Complete requests:      5797
    Failed requests:        4
    (Connect: 0, Receive: 0, Length: 4, Exceptions: 0)
    Write errors:           0
    Total transferred:      327170478 bytes
    HTML transferred:       324873720 bytes
    Requests per second:    11.59 [#/sec] (mean)
    Time per request:       2156.352 [ms] (mean)
    Time per request:       86.254 [ms] (mean, across all concurrent requests)
    Transfer rate:          638.99 [Kbytes/sec] received

    Connection Times (ms)
    min  mean[+/-sd] median   max
    Connect:       29   43 125.3     36    3051
    Processing:  1568 2108 619.6   1971   10332
    Waiting:     1266 1730 537.8   1611    8680
    Total:       1603 2152 639.1   2007   10366

    Now this is more like it. While technically performance actually dropped a bit, failed requests are almost gone. This is about the best I can hope for on my small server. Ok, there’s always MySQL tuning, but from Apache, PHP, and Wordpress I’m quite happy with these results.

blog comments powered by Disqus
TOP