Redis to the Rescue?Berlin Buzzwords2011-06-07
Who• Tim Lossen / @tlossen• backend developer at wooga• Berlin, Germany
apps.facebook.com/happy-hospital
Goals• 1 million players per day  (“DAU = daily active users”)
Goals• 1 million players per day  (“DAU = daily active users”)• small production cluster - less operational overhead - che...
Architecture
Data Model• user = single Redis hash - each entity stored in hash field   (serialized to JSON)• custom Ruby mapping layer ...
{“level”: 4,1220032045     u1                       “xp”: 241}             u1_pets   [“p7”, “p8”]                       {“...
{“level”: 4,1220032045     u1                       “xp”: 241}             u1_pets   [“p7”, “p8”]                       {“...
Setup A (July 2010)
Setup B (Nov 2010)
Setup B (Dec 2010)
Analysis• Redis virtual memory not  compatible with: -   persistence -   replication
Setup B’ (Dec 2010)
Setup C (Dec 2010)
Setup D (May 2011)
Status• peak traffic: - 3000 requests/s - 35000 Redis operations/s• average backend response time: - 10 ms
appdata.com
Goals• 1 million DAU• small production cluster
Production Cluster         Text                (1x intel core i7 X980,                 6 cores, 24 gig ram)
Goals• 1 million DAU• small production cluster
Redis Highlights• high sustained throughput /  performance• very stable• active & helpful community
Redis Gotchas• memory consumption - fragmentation!• durability
Q&A
redis.iogithub.com/tlossen/remodelwooga.com/jobs
Redis to the Rescue (Buzzwords Berlin)
Redis to the Rescue (Buzzwords Berlin)
Upcoming SlideShare
Loading in …5
×

Redis to the Rescue (Buzzwords Berlin)

4,505 views

Published on

Games in social networks offer interesting scaling
challenges, as the user base can grow explosively once they
become popular.

When wooga started work on the facebook game 'Happy
Hospital' in early 2010, we set ourselves an ambitious
goal: "Let's try to scale it to a million players per day
-- with as few servers as possible."

This constraint led us to select Redis as the main backend
storage, running on dedicated (but cheap, consumer-grade)
hardware. As an in-memory database, Redis offers an
order-of-magnitude reduction in query latency, but also
introduces new challenges in the area of durability.

This case study will recount how our backend architecture
has evolved over time, highlight the difficulties we ran
into, describe how they shaped our final setup ... and how
we came up with a new Redis persistence model (diskstore)
on the way.

Find out how many machines you *really* need for a
high-traffic game backend -- even using a 'slow' language
like Ruby.

Redis to the Rescue (Buzzwords Berlin)

  1. 1. Redis to the Rescue?Berlin Buzzwords2011-06-07
  2. 2. Who• Tim Lossen / @tlossen• backend developer at wooga• Berlin, Germany
  3. 3. apps.facebook.com/happy-hospital
  4. 4. Goals• 1 million players per day (“DAU = daily active users”)
  5. 5. Goals• 1 million players per day (“DAU = daily active users”)• small production cluster - less operational overhead - cheaper
  6. 6. Architecture
  7. 7. Data Model• user = single Redis hash - each entity stored in hash field (serialized to JSON)• custom Ruby mapping layer (“Remodel”)
  8. 8. {“level”: 4,1220032045 u1 “xp”: 241} u1_pets [“p7”, “p8”] {“pet_type”: p7 “Cat”} {“pet_type”: p8 “Dog”} {“level”: 1,1234599660 u1 “xp”: 22} u1_pets [“p3”] ... ...
  9. 9. {“level”: 4,1220032045 u1 “xp”: 241} u1_pets [“p7”, “p8”] {“pet_type”: p7 “Cat”} {“pet_type”: p8 “Dog”} {“level”: 1,1234599660 u1 “xp”: 22} u1_pets [“p3”] ... ...
  10. 10. Setup A (July 2010)
  11. 11. Setup B (Nov 2010)
  12. 12. Setup B (Dec 2010)
  13. 13. Analysis• Redis virtual memory not compatible with: - persistence - replication
  14. 14. Setup B’ (Dec 2010)
  15. 15. Setup C (Dec 2010)
  16. 16. Setup D (May 2011)
  17. 17. Status• peak traffic: - 3000 requests/s - 35000 Redis operations/s• average backend response time: - 10 ms
  18. 18. appdata.com
  19. 19. Goals• 1 million DAU• small production cluster
  20. 20. Production Cluster Text (1x intel core i7 X980, 6 cores, 24 gig ram)
  21. 21. Goals• 1 million DAU• small production cluster
  22. 22. Redis Highlights• high sustained throughput / performance• very stable• active & helpful community
  23. 23. Redis Gotchas• memory consumption - fragmentation!• durability
  24. 24. Q&A
  25. 25. redis.iogithub.com/tlossen/remodelwooga.com/jobs

×