Vending stuff from entryproperties cache with memcache plugi

Discussion corner for Developers of Serendipity.
Post Reply
FishNiX
Regular
Posts: 40
Joined: Sun Sep 02, 2007 6:32 pm

Vending stuff from entryproperties cache with memcache plugi

Post by FishNiX » Wed Apr 25, 2012 3:44 am

So I know this has been talked about a few times, but it keeps coming back in my mind that this *should* work. Of course I haven't made it work yet, so... :)

I have a read heavy site with basically _all_ unauthenticated users. I'm OK with losing some dynamic-ness as well. I am planning to drop varnish in (front of the front page only) with a short TTL. I think that should buy me a lot. Things perform fairly well on a site of ~25mi hits/month, but mysql is hammered.

Using Garvin's entryproperties plugin, I should be able to write a memcache plugin that takes those things in the entryproperties table, combines entryid + property (either cat them together or hash them together) as the key and then the value as (duh) the value. Maybe do this only for ep_cache_body + ep_cache_extended?

The trouble I have is that the entryproperties cache is not dynamic, it caches EVERYTHING during admin operations. Since memcache is ephemeral, we need the logic to check for the entry in memcache first and fall back to frontend_display_cache if it's not there (adding the entry to the cache during that fallback of course!).

I understand that there is some manipulation of frontend_display with entryproperties, is it completely overridden? Does that require messing with core or is this something that can be done completely via the plugin API? Maybe this is better if i extend entryproperties? How can I insert logic between when the framework asks for the entry and when it's fetched?

Some guidance would be very much appreciated! I wish you would translate your book, Garvin. ;)

EDIT: just to be honest, I've been staring at entryproperties for the past couple days trying to hammer this out, but I think I need to be pointed in the right direction! Thanks!

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Vending stuff from entryproperties cache with memcache p

Post by garvinhicking » Wed Apr 25, 2012 6:40 pm

Hi!
The trouble I have is that the entryproperties cache is not dynamic, it caches EVERYTHING during admin operations. Since memcache is ephemeral, we need the logic to check for the entry in memcache first and fall back to frontend_display_cache if it's not there (adding the entry to the cache during that fallback of course!).
I don't really understand that part. :-)
I understand that there is some manipulation of frontend_display with entryproperties, is it completely overridden? Does that require messing with core or is this something that can be done completely via the plugin API? Maybe this is better if i extend entryproperties? How can I insert logic between when the framework asks for the entry and when it's fetched?
The basic idea is that if the entryproperites caching option is enabled, it routes all entries frontend_display calls once during the entry creation process, saves the result of it, and writes it to ep_cache_body/extended. Then, when the entry calls the usual frontend_display hooks, the plugin simply exchanges its cached output and bypasses other frontend_display hooks. I've long not looked into the exact workings of this, so my knowledge is a few years old and I can't tell you the exact workings, I'm afraid.

I would suggest to go a similar route; hook into the backend_publish and backend_save event hooks, create your cache. I'm not sure if you are able to exchange the cache before s9y fetches the data from mysql. There should be event hooks like frontend_fetchentry or something like that, which you could use to check a cache before executing MySQL...

Hope that helps anything, sadly I can't offer you a proper solution because I simply haven't touched this caching thing for a long time; I did actually propose another "powercaching" plugin and core extension on github, but nobody ever picked up on this and helped me, so the process stalled. I myself have little experience with varnish, memcache and the likes, so I'm not really the best person to provide a solution for this. I'd need to have a lot more free time to get myself worked on that than I actually have :-(

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/

Post Reply