Hasil benchmark APC dan Memcache

Tulisan ini saya buat untuk membantu rekan-rekan yang sedang mencari solusi optimalisasi apache, apc dan memcache. APC adalah sebuah opcode cache untuk PHP (APC sendiri merupakan kependekan dari Alternative PHP Cache) yang membantu meringankan beban server saat ada client melakukan request halaman berbasis php dengan melakukan caching terhadap request tersebut, sehingga jika ada request yang sama maka server cukup mengambil data dari cache yang sudah ada. Memcache juga berfungsi lebih kurang sama, tetapi memiliki fitur yang lebih spesifik dan bisa disimpan dalam memory (yang secara teori lebih cepat). Berikut adalah spesifikasi server yang saya gunakan untuk test dan hasil lengkapnya bisa dilihat dibawah ini:

OS: FreeBSD 9.0-RELEASE 64bit
Processor: CPU: Intel(R) Xeon(R) CPU E5506 @ 2.13GHz (4 cores)
RAM: 4 GB
HD: 500 GB SATA II

Command AB: ab -n 1000 -c 10 http://aa.bb.cc.dd/ix.php

PHP 5.3.13 with Suhosin-Patch
Zend Engine v2.3.0

Tanpa Memcache dan APC
———————–
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 64495 bytes

Concurrency Level: 10
Time taken for tests: 20.776937 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 64720000 bytes
HTML transferred: 64495000 bytes
Requests per second: 48.13 [#/sec] (mean)
Time per request: 207.769 [ms] (mean)
Time per request: 20.777 [ms] (mean, across all concurrent requests)
Transfer rate: 3041.98 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 8 13 12.3 11 190
Processing: 76 192 148.5 131 1473
Waiting: 9 23 52.7 12 834
Total: 87 205 150.4 144 1485

Percentage of the requests served within a certain time (ms)
50% 144
66% 175
75% 213
80% 344
90% 398
95% 455
98% 651
99% 713
100% 1485 (longest request)

Dengan Memcache tanpa APC
————————-
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 66024 bytes

Concurrency Level: 10
Time taken for tests: 22.573895 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 66249000 bytes
HTML transferred: 66024000 bytes
Requests per second: 44.30 [#/sec] (mean)
Time per request: 225.739 [ms] (mean)
Time per request: 22.574 [ms] (mean, across all concurrent requests)
Transfer rate: 2865.97 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 8 17 13.9 13 162
Processing: 81 207 141.6 148 967
Waiting: 8 28 52.3 13 850
Total: 93 224 142.7 167 985

Percentage of the requests served within a certain time (ms)
50% 167
66% 204
75% 255
80% 356
90% 420
95% 480
98% 660
99% 741
100% 985 (longest request)

Dengan Memcache tanpa APC – test kedua
————————————–
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 66024 bytes

Concurrency Level: 10
Time taken for tests: 20.401963 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 66313240 bytes
HTML transferred: 66088015 bytes
Requests per second: 49.01 [#/sec] (mean)
Time per request: 204.020 [ms] (mean)
Time per request: 20.402 [ms] (mean, across all concurrent requests)
Transfer rate: 3174.16 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 8 16 14.7 12 150
Processing: 79 184 124.9 132 904
Waiting: 9 19 28.2 13 297
Total: 91 201 126.3 148 924

Percentage of the requests served within a certain time (ms)
50% 148
66% 180
75% 217
80% 333
90% 390
95% 431
98% 624
99% 656
100% 924 (longest request)

Dengan Memcache tanpa APC – test ketiga
—————————————
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 66024 bytes

Concurrency Level: 10
Time taken for tests: 20.193972 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 66323460 bytes
HTML transferred: 66098010 bytes
Requests per second: 49.52 [#/sec] (mean)
Time per request: 201.940 [ms] (mean)
Time per request: 20.194 [ms] (mean, across all concurrent requests)
Transfer rate: 3207.34 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 8 13 4.8 11 45
Processing: 80 186 123.1 137 731
Waiting: 9 17 29.3 12 264
Total: 92 199 123.2 151 742

Percentage of the requests served within a certain time (ms)
50% 151
66% 177
75% 206
80% 283
90% 396
95% 435
98% 592
99% 662
100% 742 (longest request)

 

Dengan APC tanpa memcache
————————-
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 68394 bytes

Concurrency Level: 10
Time taken for tests: 24.496250 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 68686163 bytes
HTML transferred: 68460938 bytes
Requests per second: 40.82 [#/sec] (mean)
Time per request: 244.962 [ms] (mean)
Time per request: 24.496 [ms] (mean, across all concurrent requests)
Transfer rate: 2738.22 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 8 17 14.1 12 179
Processing: 85 225 162.0 154 1301
Waiting: 9 31 52.0 14 421
Total: 95 242 163.5 174 1363

Percentage of the requests served within a certain time (ms)
50% 174
66% 223
75% 348
80% 379
90% 441
95% 577
98% 723
99% 815
100% 1363 (longest request)

Dengan APC tanpa memcache – test kedua
————————————–
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 68394 bytes

Concurrency Level: 10
Time taken for tests: 18.430646 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 68662803 bytes
HTML transferred: 68437578 bytes
Requests per second: 54.26 [#/sec] (mean)
Time per request: 184.306 [ms] (mean)
Time per request: 18.431 [ms] (mean, across all concurrent requests)
Transfer rate: 3638.13 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 8 13 5.6 12 50
Processing: 74 169 111.0 126 888
Waiting: 8 17 31.5 13 515
Total: 85 182 111.2 139 899

Percentage of the requests served within a certain time (ms)
50% 139
66% 163
75% 191
80% 209
90% 379
95% 406
98% 449
99% 628
100% 899 (longest request)

Dengan APC tanpa memcache – test ketiga
—————————————-
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 68394 bytes

Concurrency Level: 10
Time taken for tests: 17.405946 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 68684700 bytes
HTML transferred: 68459475 bytes
Requests per second: 57.45 [#/sec] (mean)
Time per request: 174.059 [ms] (mean)
Time per request: 17.406 [ms] (mean, across all concurrent requests)
Transfer rate: 3853.51 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 8 15 11.1 12 125
Processing: 71 156 104.3 121 864
Waiting: 8 18 27.7 13 297
Total: 81 172 105.5 135 873

Percentage of the requests served within a certain time (ms)
50% 135
66% 153
75% 168
80% 186
90% 362
95% 396
98% 444
99% 620
100% 873 (longest request)
Dengan APC + Memcache
———————
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 69923 bytes

Concurrency Level: 10
Time taken for tests: 16.147476 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 70270649 bytes
HTML transferred: 70045199 bytes
Requests per second: 61.93 [#/sec] (mean)
Time per request: 161.475 [ms] (mean)
Time per request: 16.147 [ms] (mean, across all concurrent requests)
Transfer rate: 4249.77 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 7 17 11.3 13 89
Processing: 64 143 92.1 113 914
Waiting: 8 24 38.8 14 515
Total: 73 160 93.5 131 936

Percentage of the requests served within a certain time (ms)
50% 131
66% 148
75% 163
80% 179
90% 234
95% 373
98% 434
99% 630
100% 936 (longest request)

Dengan APC + Memcache – test kedua
———————————-
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 69923 bytes

Concurrency Level: 10
Time taken for tests: 15.39564 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 70148000 bytes
HTML transferred: 69923000 bytes
Requests per second: 66.49 [#/sec] (mean)
Time per request: 150.396 [ms] (mean)
Time per request: 15.040 [ms] (mean, across all concurrent requests)
Transfer rate: 4554.85 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 7 16 10.5 12 76
Processing: 71 130 72.0 109 625
Waiting: 8 17 18.2 13 281
Total: 81 147 73.6 127 654

Percentage of the requests served within a certain time (ms)
50% 127
66% 142
75% 154
80% 162
90% 203
95% 354
98% 397
99% 430
100% 654 (longest request)

Dengan APC + Memcache – test ketiga
———————————–
Completed 800 requests
Completed 900 requests
Finished 1000 requests
Server Software: Apache/2.2.22
Server Hostname: aa.bb.cc.dd
Server Port: 80

Document Path: /ix.php
Document Length: 69923 bytes

Concurrency Level: 10
Time taken for tests: 15.96684 seconds
Complete requests: 1000
Failed requests: 0
Write errors: 0
Total transferred: 70191804 bytes
HTML transferred: 69966579 bytes
Requests per second: 66.24 [#/sec] (mean)
Time per request: 150.967 [ms] (mean)
Time per request: 15.097 [ms] (mean, across all concurrent requests)
Transfer rate: 4540.47 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 6 18 11.4 14 69
Processing: 66 130 72.6 109 654
Waiting: 7 20 23.6 14 302
Total: 76 149 75.0 129 664

Percentage of the requests served within a certain time (ms)
50% 129
66% 147
75% 159
80% 169
90% 204
95% 359
98% 404
99% 453
100% 664 (longest request)

"Benchmark APC Memcache"

Batasan:
1. PHP, Apache belum di tuning
2. APC dan memcache belum dituning
3. OS/Kernel belum dituning

Kesimpulan:
1. Sementara perbandingan APC dan Memcache sendiri boleh dibilang memcache menang sedikit.
2. Untuk performance lebih bagus kombinasi APC + memcache akan sangat membantu untuk loading website.
3. Jika anda menggunakan memcache, pastikan script Anda sudah mendukung fitur memcache atau hanya menjadi mubazir
4. Untuk static file seperti javascript, css dan image sebaiknya menggunakan server terdistribusi untuk membantu yang disebut ‘first connect time impressive’

semoga bermanfaat

About Kalpin Erlangga Silaen

Suka membaca
This entry was posted in IT, SysAdmin. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *