Skip to content

Support Memcached and/or ElasticCache #263

Open

Description

@waldoj

If we're going to move to a consuming-our-own-API model, then that's going to benefit from an object caching system. Inevitably, that means Memcached or/or ElastiCache. ElastiCache has the advantage of being a turn-key setup, although Memcached seems awfully easy to install.

This ought to be pretty easy to interface with. The method to retrieve each type of content—say, a law—would take the file off the filesystem, unless Memcached is installed, in which case it pulls it out of Memcached.

Activity

  1. krusynth commented on Mar 31, 2013

    @krusynth
    Member

    The only issue here is that you need as much memory as you've got data. Considering how large our dataset is we're only going to get a benefit from pure in-memory caches on things like the laws list (which is not resource intensive) and possibly a few of the more popular pages - on an "average" server, everything else will page-out too quickly to be useful. This might be a premature optimization as a result.

    Honestly, if we're using static json files that have been pre-generated to respond to api requests, we'll get a much bigger benefit since it's just disk IO - which is relatively fast (though not as fast as in-memory ops) and very cheap compared to memory.

  2. waldoj commented on Mar 31, 2013

    @waldoj
    MemberAuthor

    Memcached is a "least recently used" cache—it will happily optimize in the memory available to it. (Unlike APC, which has the annoying habit of deleting everything when the cache fills up.) So if it just caches the 500 laws requested the most frequently, that's pretty good. I don't see why it has to contain the whole legal code.

    Separately, though, it's entirely possible that this is premature optimization. Alternately, it may well be that this is something that APC can handle quite nicely. If Virginia Decoded is any indicator, the long tail is very, very long—only a couple of dozen laws are regularly requested. Storing those in APC might provide a strong benefit to the largest percentage of the traffic (admittedly a low percentage), making it unnecessary to use an object caching system.

  3. waldoj commented on Aug 22, 2013

    @waldoj
    MemberAuthor

    Note that ElastiCache only works for sites hosted on EC2.

  4. waldoj commented on Sep 5, 2013

    @waldoj
    MemberAuthor

    Now that we're keeping JSON as static files, I think that this is premature optimization. This could be a useful feature for some high-traffic sites, though, so I've moved it past v1.0.

  5. waldoj commented on Jan 28, 2014

    @waldoj
    MemberAuthor

    I recently added Memcached support to another project. It's absurdly easy, and the payoff is pretty big. This will be a simple addition.

  6. waldoj commented on Oct 15, 2014

    @waldoj
    MemberAuthor

    See also #516.

  7. waldoj commented on Oct 17, 2014

    @waldoj
    MemberAuthor

    There remains one more thing to do: serialize and unserialize material when it goes in and out of the cache.

  8. reopened this on Oct 17, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions