[erlang-questions] Caching server
Tue Feb 22 17:45:32 CET 2011
On Feb 22, 2011, at 7:59 AM, Nicholas Wieland wrote:
> My question wasn't really about the example, but about the
> architecture itself, I wanted to know if that was a "possible"
> production architecture, and I think you all clarified my doubts.
(jumping in late)
As nox graciously pointed out, my pcache project (a knockoff of
Jay's Concurrent Caching paper ) does what you describe. I use
pcache for storing compiled website templates, rendered content (wiki
markup -> HTML), generated rss feeds, appcast feeds, and half a dozen
A benefit of putting each cache item in its own process is you can
use erlang's receive/after statement to auto-garbage-collect cache
items if they go unused for a period of time (pattern: exploit
erlang's built in event loop to simplify your code). You can think of
the cache data as entirely stored in the spawned function's argument
. When the timeout is reached, the spawned processes dies, and the
cache data get garbage collected.
Recently I converted the pcache API to store cache items in ets
directly. With ets as a cache backend, you can get compression with
just an option to ets (since R14B01). Individual processes are still
spawned to terminate cache items when the TTL is over. Each process
goes from storing the data (as in pcache) to just being a timeout to
delete the cache item when the TTL expires .
Matt Stancliff San Jose, CA
@mattsta iPhone: 678-591-9337
"The best way to predict the future is to invent it." --Alan Kay
More information about the erlang-questions