Change website

From Jan 16 2015,


All post content will be move to we's offical website with many content...

Can access website here: http://justox.com

Thanks for your visit!

Wednesday, 18 December 2013

XCache v3.0.1, More Performance For PHP Apps

After writing about how to Boosting PHP Apps Performance with APC, i finally got time to consider making comparison about those two. As i wrote in previous post, this will maybe not meet your requirements and you will maybe need to use APC instead.

After removing APC, we installed XCache v3.0.1 and then run few tests again and again with AB and Tsung, with APC we had about 300 requests per second, but guess what.. with XCache we got almost same number of requests per second without any configuration eg. out of the box!
Now what i wanted to do is try to find a way how to maximize number of requests per second. Here is preview of my final config :
# enable xcache module for php
extension=xcache.so

# we want admin interface, setup username and password (password is in MD5) and location to xcache admin GUI is at /usr/share/xcache/htdocs/ -- Debian/Ubuntu
xcache.admin.enable_auth = On
xcache.admin.user        = ""
xcache.admin.pass        = ""

# for my scripts, its enough to have 128MB op code cache size, anyway i don't use variable caching with xcache
xcache.size             = 128M
# how xcache get shared memory
xcache.shm_scheme       = "mmap"
# i want 4 chunks for splitting memory, you can also test a bit with 2-4-6, depending on your hardware
xcache.count            = 4
# more slots means more memory usage but is faster
xcache.slots            = 8K
# how long we want file to be in cache (in milliseconds), 0 means forever
xcache.ttl              = 0
# garbage collection interval, 0 means never
xcache.gc_interval      = 0

# it's same as above but for variables, since im not using variable caching i will disable it
xcache.var_size         = 0M
xcache.var_count        = 0
xcache.var_slots        = 0K
xcache.var_ttl          = 0
xcache.var_maxttl       = 0
xcache.var_gc_interval  = 0

xcache.test             = Off
xcache.readonly_protection = On
xcache.mmap_path        = "/tmp/xcache"
xcache.coredump_directory = ""
# we want to cache, so we will enable it, if size = 0, opcode caching is disabled
xcache.cacher           = On
# statistics for opcode caching if file updated
# Thanks David : it determines whether Xcache/PHP check the filesystem to see if the file has changed or not
xcache.stat             = On
# didn't find what this gives, there is no better performance because that so i will just disable it
xcache.optimizer        = Off

# those guys can hur your performance, should be enabled only on debug
xcache.coverager        = On
xcache.coveragedump_directory = ""
After we checked and tested with AB, ab -c 10 -n 100 http://www.codestance.com/, we find that normally have about 450-470 requests per second which is better than APC, check this out :
Concurrency Level:      10
Time taken for tests:   0.209 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      2414800 bytes
HTML transferred:       2383300 bytes
Requests per second:    463.41 [#/sec] (mean)
Time per request:       98.948 [ms] (mean)
Time per request:       9.895 [ms] (mean, across all concurrent requests)
Transfer rate:          248729.37 [Kbytes/sec] received
If you find this interesting, try it yourself and watch performance improvement after APC.
Please note that you need to run dozens of tests and after changing any parameter you will need to reload php to see any results improvement. You can also write a comment about your tests so we can make better comparison :)
Happy Hacking !

No comments:

Post a Comment