VPSサーバチューニング 3ヶ月目

WordPressでサイトを始めて3ヶ月。チューニングできることは減ってきました。

httpレスポンスは安定。ただし!?

httping_resp2_riscascape_net-201503
高負荷時のhttpレスポンス低下を更に抑えることができました。ただし!?原因が分かりません。というのも改善のトリガーがOS再起動によるものだから。
今までずっとhttpdtoとclamdパラメータを弄ってはデーモンの再起動を行っていましたが効果は微妙でした。それがOS再起動で一気に改善となると、チューニングの効果があったのは嬉しいものの何が効果的なのかが分からず消化不良な感じ。

消費メモリ・SWAPサイズはほぼ安定

memory-pinpoint_201503
SWAPサイズは大分減りました。3/17(Week12前半)にswappinessを60→40に変更したこともあってか、最大600MB以上確保していたSWAPサイズが今では最大100MBほどに。SWAPメモリの活用方法は諸説ありますが、少ないに越したことがないと思います。

現在のprefork.cはこんなところ。StartServers|MinSpareServers|MaxSpareServersを先月の10から8に削りました。この変更によりプロセスがMaxRequestsPerChildに達したことで再起動するタイミングがずれはじめ、httpdプロセス合計の最大消費メモリが減るのではないかと狙ってみたのですが効果は不明です。

/etc/httpd/conf/httpd.conf
<ifmodule prefork.c>
StartServers      8
MinSpareServers   8
MaxSpareServers   8
ServerLimit       10
MaxClients        10
MaxRequestsPerChild  100
MaxMemFree 1024
</ifmodule>

my.cnfのパラメータとmysqltuner結果

現在のmy.cnfです。httpdのMaxClientsが10なので、mysqlのmax_connectionsも抑えてみました。

cat /etc/my.cnf

skip-innodb
query_cache_size=8M
thread_cache=32
tmp_table_size=24M
max_heap_table_size=24M
max_connections = 32

これを受けたmysqltunerの結果はコチラ。

# mysqltuner
-------- Performance Metrics -------------------------------------------------
[--] Up for: 16d 9h 53m 41s (1M q [0.723 qps], 35K conn, TX: 3B, RX: 119M)
[--] Reads / Writes: 96% / 4%
[--] Total buffers: 40.0M global + 2.7M per thread (32 max threads)
[OK] Maximum possible memory usage: 128.0M (12% of installed RAM)
[OK] Slow queries: 0% (0/1M)
[OK] Highest usage of available connections: 31% (10/32)
[OK] Key buffer size / total MyISAM indexes: 8.0M/234.0K
[OK] Key buffer hit rate: 99.7% (577K cached / 1K reads)
[OK] Query cache efficiency: 89.1% (776K cached / 872K selects)
[OK] Query cache prunes per day: 0
[OK] Sorts requiring temporary tables: 0% (0 temp sorts / 11K sorts)
[!!] Temporary tables created on disk: 31% (3K on disk / 10K total)
[OK] Thread cache hit rate: 99% (10 created / 35K connections)
[!!] Table cache hit rate: 5% (35 open / 666 opened)
[OK] Open file limit used: 6% (69/1K)
[OK] Table locks acquired immediately: 99% (40K immediate / 40K locks)

-------- Recommendations -----------------------------------------------------
General recommendations:
    Enable the slow query log to troubleshoot bad queries
    When making adjustments, make tmp_table_size/max_heap_table_size equal
    Reduce your SELECT DISTINCT queries without LIMIT clauses
    Increase table_cache gradually to avoid file descriptor limits
Variables to adjust:
    tmp_table_size (> 24M)
    max_heap_table_size (> 24M)
    table_cache (> 64)

tmp_table_size|max_heap_table_size|table_cacheを増やせと言っていますが、効果がどれくらいあるのか不明なので消費メモリを増やしてまで効果があるのか見極めが必要なところです。値を1.5倍くらいに増やし1ヶ月様子見を行ってみます。