Guys,

Under high load, Symfony apps using sfFunctionCache could stress out
the server trying to rebuild a cache file.

The way sfFunctionCache and sfFileCache play together is as follows:

- cache key is generated
- if cache file exists and is not already expired, apply shared lock
to cache file, then serve it & unlock
- if not, run the callable to get the data for caching, then lock,
write cache file, unlock

What if the callable takes a good length of time (say 5-8 secs) to
assemble the data for recaching?
Under high load with sfFunctionCache/sfFileCache, during those 5-8
secs, you may receive more page hits, and force the recaching process
on each hit as there is no logic to determine whether a single process
is already progressing a recache. This means load builds up
unecessarily on the server until all the recache processes have
completed.

You could argue if its going to take more than a few secs to recache
data, it should be passed to cron to sort out "offline" rather than
forcing the lucky user who hits the expired data to wait while
recaching is completed.

But you could also argue better cache file management could also go
some way to making this less painful.

I propose the following process instead, better illustrated in a
diagram I have uploaded:

http://www.ryangrenz.com/caching (everything is in there)

I have implemented them myself roughly in 2 new classes which extend
both sfFunctionCache and sfFileCache separately so you can see what I
mean, although the way I've done it I'm not 100% sure I like yet as
the locking logic should imo be in the FileCache class not
FunctionCache... but I'm still working on it anyway so...

I am very keen to hear any feedback on this approach, and if anyone is
able to help me check over and/or develop on the classes I have
written to support it that'd also be great.
If anyone has any better ideas for caching strategies that minimise
the wait for end users, but ensure load is kept to a minimum I'm all
ears too!

Cheers,

Ryan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-devs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to