开发者

memcached vs. internal caching in PHP?

I'm working on some old(ish) software in PHP that maintains a $cache array to reduce the number of SQL queries. I was thinking of just putting memcached in its place and I'm wondering whether or not to get rid of the internal caching. 开发者_运维问答Would there still be a worthwihle performance increase if I keep the internal caching, or would memcached suffice?


According to this blog post, the PHP internal array is way faster than any other method:

Cache Type                Cache Gets/sec

Array Cache                       365000
APC Cache                          98000
File Cache                         27000
Memcached Cache (TCP/IP)           12200
MySQL Query Cache (TCP/IP)          9900
MySQL Query Cache (Unix Socket)    13500
Selecting from table (TCP/IP)       5100
Selecting from table (Unix Socket)  7400


It seems likely that memcache (which is implemented on the metal) would be faster than some php interpreted caching scheme.

However: if it's not broken, don't fix it.

If you remove the custom caching code, you might have to deal with other code that depends on the cache. I can't speak for the quality of the code you have to maintain but it seems like one of those "probably not worth it" things.

Let me put it this way: Do you trust the original developer(s) to have written code that will still work if you rip out the caching? (I probably wouldn't)

So unless the existing caching is giving you problems I would recommend against taking it out.


There's an advantage in using memcache vs local caching if:

1) you have mulitple webservers running off the same database, and have memcache set up to run across multiple nodes

2) the database does not implement query result caching or is very slow to access

Otherwise, unless the caching code is very poor, you shouldn't expect to see much performance benefit.

HTH

C.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜