Today I tested some different configurations for Magento to see if I could boost the performance. One major aspect of this is which caching to use (internal, memcached, APC or OpCode) in combination with different PHP versions (5.3, 5.4 and 5.5). The differences in these tests are big, but is the fastest solution also the best one?
The setup I used is as follows:
- Magento Community Edition 188.8.131.52.
- I created one category with one simple product.
- Vagrant box for testing with 2 CPU’s and 4GB Ram, Ubuntu precise 64.
For testing I created an automated CasperJS script that does the following:
- Open the homepage.
- Clear cookies.
- Go to the category page.
- Go to the product page.
- Add the product to the cart.
- Do this 5 times in a row.
I wanted to test the following caching methods:
- Magento’s built-in caching with files.
- PHP 5.5’s built-in OpCode caching.
And I wanted to test them with the following PHP versions:
- PHP 5.3
- PHP 5.4
- PHP 5.5
In milliseconds, these are the results (from slowest to fastest):
|PHP 5.4, internal caching||18235 ms|
|PHP 5.3, internal caching||17760 ms|
|PHP 5.5, internal caching||16410 ms|
|PHP 5.5, memcached||14997 ms|
|PHP 5.4, memcached||12071 ms|
|PHP 5.5, OpCache||11800 ms|
|PHP 5.3, APC||11458 ms|
|PHP 5.3, memcached||10507 ms|
|PHP 5.4, APC||9269 ms|
|PHP 5.5, memcached + OpCache||8661 ms|
|PHP 5.5, APC + OpCache||unstable|
|PHP 5.5, APC||unstable|
As you can see in the above results, PHP 5.5 with a combination of memcached and OpCache is the fastest. If you compare it with the slowest results you even get a result that is more than twice as fast. However, if you take in consideration that Magento itself states it’s compatible up to PHP 5.4, PHP 5.5 might not be the safest bet. In that case PHP 5.4 with APC might be the best configuration for your shop. But… if your shop relies on 3rd party extensions, it might even be possible that PHP 5.4 is not an option for you. So if you’re stuck with PHP 5.3, memcached is your friend.
According to these results, if you’re on PHP 5.3 you should use memcached and if you’re on PHP 5.4 you should use APC. And for those living on the edge and running Magento on PHP5.5: give the combination memcached/OpCache a try! However, as I pointed out in the beginning, this test is very small. All I did was add a product to the cart. I haven’t even tested stuff like indexing, the checkout process or admin actions. There also is probably a lot of performance to gain by tweaking your database configuration (that’s something I’m planning on doing soon).
But we all can agree on one thing: whatever PHP version you have, using the built-in file system as caching is (besides no cache at all) not the best solution.
Visitors give this article an average rating of 4.5 out of 5.
How would you rate this article?
★ ★ ★ ★ ★