Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: bbpress and memcache?


_ck_
Participant

@_ck_

Let’s review this from scratch.

WordPress and bbPress 1.0 has what we call an object cache. That is simply a pool of users, forums,topics, and posts and meta as they are passed between mysql and the application (wordpress/bbpress). It’s just another layer between mysql and bbpress.

Typically these “objects” are lost after every page load because they are no longer in regular short-term computer memory and have to be fetched again from mysql.

On a single computer system with a fast mysql server and fast disk cache, this typically is not a big problem. As a site has to scale this does become a problem because there is only one mysql source and everything has to be fetched from it.

Using a poorly configured WordPress or bbPress system with badly written or improperly running plugins, if each page load requires 30-40 queries, and you have 1000 users connected simultaneously at once, that’s a huge problem.

Memcache is a common pool of memory that doesn’t go away after each page load. It’s centralized on one server so multiple servers can all find it easily. It was invented by LiveJournal after they hit a growth limit with mysql.

The Memcache to Object Cache interface plugin for WordPress/bbPress 1.0 allows the fetching from mysql to be skipped IF the user/forum/topic/posts happen to be in the previously accessed pool in that centralized memory. Every time a query is made, the resulting data is saved in the collective memory which is retained inbetween page loads. It’s a common, shared memory.

However Memcache was written to talk over tcp/ip between MULTIPLE servers. For a single server setup it’s pointless and stupid and way too much overhead.

Now, on a single server, you could still use a persistent object cache with one of the other lesser known plugins that mimic what the memcache interface does. There is one for Eaccelerator, one for APC and one for Xcache.

However, all of these caches do almost the same thing as MySQL’s cache. They are all tied to the particular kind of query that is done and if it matches the previous set of data. The object cache still has to de-serialize data if it’s serialized.

MySQL on a single server system does not use tcp/ip to communicate with bbPress if it’s properly configured (and most are unless your host is greedy and stupid and uses a central mysql server separate from your regular server). So MySQL with a properly configured cache is almost as fast on a single server setup than a persistent object cache (unless MySql is overloaded in the first place).

So in conclusion, if you are on a shared host, object caching is not a viable solution for you because you can’t get any of the persistant memory options installed anyway. If you are on a single server setup but not dealing with a large number of connections, the mysql cache is probably going to be near the performance of a persistent object cache, and the real memcache would never be used in the first place.

Memcache was meant for large, inefficient installs like WordPress.com

WP.com serves many thousands of people simultaneously from many different servers. It uses several dozen queries per page load. It absolutely cannot just rely on the mysql cache, even with dedicated mysql servers. The average wordpress/bbpress user does not face these problems typically.

If you have your own VPS or dedicated server you should be installing an opcode cache like Eaccelerator, APC or Xcache and turning on the shared memory pool option (typically during compile). Then you should make sure your mysql cache is ON and setup properly. Then you should make sure your pages are not using too many queries. If you’ve done all that and you have so many simultaneous visitors that your mysql is running too high a load and your pages are still too slow, then you can look at one of the persistent object cache modules for wordpress and port them to bbpress.

None of the bbPress installs in the Top 10, are using memcache or any kind of object cache for that matter (including wp.org which is using bbPress 0.9). So I sincerely question the need of anyone else using an object cache just yet unless they have made their install extremely inefficient somehow or have a horrible host.

Skip to toolbar