Main menu

Post navigation

Wincache vs APC Data Performance

I was interested in the performance of PHP’s APC cache vs the new Wincache touted by Microsoft. Essentially Wincache is APC for Windows (no duh!). I am only interested in their performance at storing variables and arrays in memory, and not any of the OPCODE stuff. Part of the reason is because I think they would be equally performant, and another part is that I have no f’ing idea about OPCODEs. Another thing is that I am not testing on server farms, so I was only evaluating single-server solutions (i.e. ignoring memcache) Enough with the hors d’oeuvres, let’s get to the meat of it.

I wrote a result script that created 20,000 variables with random strings inside each cache. Then read those items out into a variable. Pretty simple, not much to it. The results:

APC: 0.61s

WinCache: **0.59s**

They are basically identical. Not much more to say here. Wincache beats it by a slight amount, but not much that you’d notice. For me, I think going with APC gives you the benefit of being platform independent. On the other side Wincache seems to be better built for a Windows environment and has an automatic way to handle sessions in memory (rather than cumbersome filesystem).

They are both really easy to install as well, so it’s a tossup there. Personally I am sticking with APC due to platform independence, and the fact that CodeIgniter has a **very** nice caching library that already has APC code written. Maybe I’ll stop being lazy and write a Wincache library for CI’s cache class.

Edit: I have actually created a Wincache library for CodeIgniter because it actually works much better in a production Windows environment. APC throws random errors, and there isn’t much support running it on Windows. Wincache just works (TM). Here is a link to my first contribution to the CodeIgniter project.

I would still be interested in an OPCODE comparison. I am also using APC because of library usage, but I agree that it is not as stable as Wincache and it’s so much of a bear to install that I cringe at the very idea. But I’m glad that my seat-of-the-pants impressions match your numbers.

mikemurko

I’d like to try set that up. Do you have any ideas on how to test that type of functionality? What sort of computations would see great benefit for opcode caching? If I made a page that looped and put out 10,000 lines – ran 3x without caching, with wincache, and with apc – would the execution time be different? Or is it more for output of templates?

I’m noticing some weird caching going on with Wincache. When I release my code into production – sometimes the browser doesn’t reflect those changes. It’s usually an issue when I don’t change the HTML (i.e. changing some model method or background code) … the changes won’t be reflected until a few minutes pass or I restart the IIS site. I suspect Wincache – but this could be IIS behaviour as well.