Akins, Brian wrote:

The current 2.1 mod_disk_cache allows any number of workers to be actively
trying to cache the same object.  This is because of the use of
apr_file_mktemp.

This patch makes the tempfiles the same per cache object rather than
"random".  I basically added a temp_file() that mimics data_file() and
header_file().

This way only one thread is trying to cache that object and avoids a
"thundering herd." The other threads fail the EXCL flag, and serve like
normal.

This is very cool. On my list of things to do was to handle something similar for serving from the cache as well - again to avoid a thundering herd against backend servers while a file is being cached.

Basically the cache could serve from a half cached file, serving the data as the cache file grows. In the mem cache case this is trivial, as a simple flag saying "still busy" can indicate whether an EOF on a cached file is actually the EOS or whether the stream should back off for a bit, and try read some more a bit later. The disk cache might be a bit more involved, but the idea would be the same.

Regards,
Graham
--

Reply via email to