Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ


Choose your language

InfoQ Homepage News Twemproxy – Proxy For MemCached And Redis

Twemproxy – Proxy For MemCached And Redis

This item in japanese

Twemproxy is a proxy server that allows you to reduce the number of open connections to your Memcached or Redis server.

What is Twemproxy useful for? It can

  • reduce the number of connections to your cache server by acting as a proxy
  • shard data automatically between multiple cache servers
  • support consistent hashing with different strategies and hashing functions
  • be configured to disable nodes on failure
  • run in multiple instances, allowing client to connect to the first available proxy server
  • Pipelining and batching of requests and hence saving of round-trips

Salvatore Sanfilippo(@antirez), the creator of Redis, wrote an article about how this can allow a Redis cluster to function even before the Redis-cluster feature is available, without losing much performance in most cases –

What's awesome about Twemproxy is that it can be configured both to disable nodes on failure, and retry after some time, or to stick to the specified keys -> servers map. This means that it is suitable both for sharding a Redis data set when Redis is used as a data store (disabling the node ejection), and when Redis is using as a cache, enabling node-ejection for cheap (simple) high availability.

This Thing Is Fast. Really fast, it is almost as fast as talking directly with Redis. I would say you lose 20% of performances at worst.

My only issue with performances is that IMHO MGET could use some improvement when the command is distributed among instances.

Twemproxy was open-sourced by Twitter earlier this year supporting Memcached and recently added support for Redis as well. Twitter uses cache servers extensively to deliver upto 300k tweets per minute; you can have a look at the presentation Real-Time Delivery Architecture At Twitter for more information. 

Rate this Article