Apacheチューニング: ロギングを高速化する

という記事に

CODE:
  1. BufferedLogs On

によるアクセスログのバッファリングの記事がありました。試したことのないディレクティブだったので、実験してみました。

環境は

  • CentOS5
  • Apache/2.2.4

で、貧弱なサーバーです。

チェック方法

CODE:
  1. /usr/local/apache2/bin/ab -n 10000 -c 100 http://stockholm/

1回実行後に2回さらに実行して、後半2回の平均を取る

設定1)バッファリングなしで、cronlogなし

※CustomLog logs/access_log combined

CODE:
  1. Server Software:        Apache/2.2.4
  2. Server Hostname:        stockholm
  3. Server Port:            80
  4.  
  5. Document Path:          /
  6. Document Length:        44 bytes
  7.  
  8. Concurrency Level:      100
  9. Time taken for tests:   11.973132 seconds
  10. Complete requests:      10000
  11. Failed requests:        0
  12. Write errors:           0
  13. Total transferred:      2909570 bytes
  14. HTML transferred:       441452 bytes
  15. Requests per second:    835.20 [#/sec] (mean)
  16. Time per request:       119.731 [ms] (mean)
  17. Time per request:       1.197 [ms] (mean, across all concurrent requests)
  18. Transfer rate:          237.28 [Kbytes/sec] received
  19.  
  20. Connection Times (ms)
  21. min  mean[+/-sd] median   max
  22. Connect:        0   12  11.3     10      74
  23. Processing:    20  105  16.5    105     482
  24. Waiting:        9   73  26.5     74     461
  25. Total:         23  118  19.6    117     493
  26.  
  27. Percentage of the requests served within a certain time (ms)
  28. 50%    117
  29. 66%    122
  30. 75%    126
  31. 80%    128
  32. 90%    137
  33. 95%    145
  34. 98%    155
  35. 99%    161
  36. 100%    493 (longest request)
  37.  
  38. Server Software:        Apache/2.2.4
  39. Server Hostname:        stockholm
  40. Server Port:            80
  41.  
  42. Document Path:          /
  43. Document Length:        44 bytes
  44.  
  45. Concurrency Level:      100
  46. Time taken for tests:   12.232209 seconds
  47. Complete requests:      10000
  48. Failed requests:        0
  49. Write errors:           0
  50. Total transferred:      2900000 bytes
  51. HTML transferred:       440000 bytes
  52. Requests per second:    817.51 [#/sec] (mean)
  53. Time per request:       122.322 [ms] (mean)
  54. Time per request:       1.223 [ms] (mean, across all concurrent requests)
  55. Transfer rate:          231.52 [Kbytes/sec] received
  56.  
  57. Connection Times (ms)
  58. min  mean[+/-sd] median   max
  59. Connect:        0    0   2.1      0      28
  60. Processing:    15  120 237.3    115   12182
  61. Waiting:       14  120 237.3    115   12181
  62. Total:         15  120 237.4    115   12182
  63.  
  64. Percentage of the requests served within a certain time (ms)
  65. 50%    115
  66. 66%    115
  67. 75%    116
  68. 80%    116
  69. 90%    120
  70. 95%    128
  71. 98%    142
  72. 99%    150
  73. 10012182 (longest request)

Requests per second: 826.355 (平均)

設定2)バッファリングなしで、cronlogあり

※CustomLog "|/usr/local/sbin/cronolog /usr/local/apache2/logs/access_log.%Y-%m-%d" combined

CODE:
  1. Server Software:        Apache/2.2.4
  2. Server Hostname:        stockholm
  3. Server Port:            80
  4.  
  5. Document Path:          /
  6. Document Length:        44 bytes
  7.  
  8. Concurrency Level:      100
  9. Time taken for tests:   12.177233 seconds
  10. Complete requests:      10000
  11. Failed requests:        0
  12. Write errors:           0
  13. Total transferred:      2900000 bytes
  14. HTML transferred:       440000 bytes
  15. Requests per second:    821.20 [#/sec] (mean)
  16. Time per request:       121.772 [ms] (mean)
  17. Time per request:       1.218 [ms] (mean, across all concurrent requests)
  18. Transfer rate:          232.57 [Kbytes/sec] received
  19.  
  20. Connection Times (ms)
  21. min  mean[+/-sd] median   max
  22. Connect:        0    0   1.7      0      29
  23. Processing:    18  120  80.6    113    3127
  24. Waiting:       17  117  61.1    112    2298
  25. Total:         18  120  80.6    113    3127
  26.  
  27. Percentage of the requests served within a certain time (ms)
  28. 50%    113
  29. 66%    114
  30. 75%    115
  31. 80%    115
  32. 90%    116
  33. 95%    118
  34. 98%    149
  35. 99%    558
  36. 100%   3127 (longest request)
  37.  
  38. Server Software:        Apache/2.2.4
  39. Server Hostname:        stockholm
  40. Server Port:            80
  41.  
  42. Document Path:          /
  43. Document Length:        44 bytes
  44.  
  45. Concurrency Level:      100
  46. Time taken for tests:   12.72722 seconds
  47. Complete requests:      10000
  48. Failed requests:        0
  49. Write errors:           0
  50. Total transferred:      2900000 bytes
  51. HTML transferred:       440000 bytes
  52. Requests per second:    828.31 [#/sec] (mean)
  53. Time per request:       120.727 [ms] (mean)
  54. Time per request:       1.207 [ms] (mean, across all concurrent requests)
  55. Transfer rate:          234.58 [Kbytes/sec] received
  56.  
  57. Connection Times (ms)
  58. min  mean[+/-sd] median   max
  59. Connect:        0    0   1.6      0      28
  60. Processing:     1  119 1051.5      3   11423
  61. Waiting:        0   17 131.2      3    8634
  62. Total:          1  119 1051.5      3   11423
  63.  
  64. Percentage of the requests served within a certain time (ms)
  65. 50%      3
  66. 66%      4
  67. 75%      6
  68. 80%      7
  69. 90%      8
  70. 95%    113
  71. 98%    654
  72. 99%   1101
  73. 10011423 (longest request)

Requests per second: 824.755 (平均)

設定3)バッファリングありで、cronlogあり

※CustomLog "|/usr/local/sbin/cronolog /usr/local/apache2/logs/access_log.%Y-%m-%d" combined

CODE:
  1. Server Software:        Apache/2.2.4
  2. Server Hostname:        stockholm
  3. Server Port:            80
  4.  
  5. Document Path:          /
  6. Document Length:        44 bytes
  7.  
  8. Concurrency Level:      100
  9. Time taken for tests:   11.347721 seconds
  10. Complete requests:      10000
  11. Failed requests:        0
  12. Write errors:           0
  13. Total transferred:      2909280 bytes
  14. HTML transferred:       441408 bytes
  15. Requests per second:    881.23 [#/sec] (mean)
  16. Time per request:       113.477 [ms] (mean)
  17. Time per request:       1.135 [ms] (mean, across all concurrent requests)
  18. Transfer rate:          250.36 [Kbytes/sec] received
  19.  
  20. Connection Times (ms)
  21. min  mean[+/-sd] median   max
  22. Connect:        0   11  10.7      8      70
  23. Processing:    18  100  16.8    100     457
  24. Waiting:        9   71  26.0     79     406
  25. Total:         18  111  20.6    110     476
  26.  
  27. Percentage of the requests served within a certain time (ms)
  28. 50%    110
  29. 66%    115
  30. 75%    119
  31. 80%    122
  32. 90%    132
  33. 95%    141
  34. 98%    151
  35. 99%    157
  36. 100%    476 (longest request)
  37.  
  38. Server Software:        Apache/2.2.4
  39. Server Hostname:        stockholm
  40. Server Port:            80
  41.  
  42. Document Path:          /
  43. Document Length:        44 bytes
  44.  
  45. Concurrency Level:      100
  46. Time taken for tests:   11.505531 seconds
  47. Complete requests:      10000
  48. Failed requests:        0
  49. Write errors:           0
  50. Total transferred:      2900000 bytes
  51. HTML transferred:       440000 bytes
  52. Requests per second:    869.15 [#/sec] (mean)
  53. Time per request:       115.055 [ms] (mean)
  54. Time per request:       1.151 [ms] (mean, across all concurrent requests)
  55. Transfer rate:          246.14 [Kbytes/sec] received
  56.  
  57. Connection Times (ms)
  58. min  mean[+/-sd] median   max
  59. Connect:        0   35  27.7     32     107
  60. Processing:    26   78  17.8     75     131
  61. Waiting:        1   40  24.2     37     110
  62. Total:         27  113  16.0    114     212
  63.  
  64. Percentage of the requests served within a certain time (ms)
  65. 50%    114
  66. 66%    120
  67. 75%    124
  68. 80%    127
  69. 90%    134
  70. 95%    140
  71. 98%    144
  72. 99%    146

Requests per second: 875.19 (平均)

やはり5-6%はあきらかに効果があるようです。

静的コンテンツ用のサーバーの場合は使える設定だと思います。

ちなみに

設定4)アクセスログの出力自体を停止

の場合は

Requests per second: 902.15 (平均)

なのでバッファリングした時と比べると1%くらいしか性能向上しませんでした。