marshallpenguin
marshallpenguin

Reputation: 177

using memcached for very small data, good idea?

I have a very small amount of data (~200 bytes) that I retrieve from the database very often. The write rate is insignificant.

I would like to get away from all the unnecessary database calls to fetch this almost static data. Is memcached a good use for this? Something else?

If it's of any relevance I'm running this on GAE using python. The data in question could be easily (de)serialized as json.

Upvotes: 2

Views: 347

Answers (2)

David Underhill
David Underhill

Reputation: 16243

Memcache is well-suited for this - reading from the datastore is much more expensive than reading from memcache. This is especially true for small amounts of data for which the cost to retrieve is dominated by latency to the datastore.

If your app receives enough requests that instances typically stay alive for a little while, then you could go one step further and use App Caching to largely avoid memcache too. (Basically, cache the value in a global variable, and also app-cache the time the value was last updated. Provide an accessor for the value which retrieves the latest from memcache/db if it hasn't been updated in X minutes). Memcache is pretty cheap though, so this extra work might only make sense if you access this variable rather frequently.

Upvotes: 4

liori
liori

Reputation: 42267

If it changes less often than once per day, you could just hardcode it in webapp code, and reupload the file each time it changes.

Upvotes: -2

Related Questions