Scalarium and CouchDB

31
Scalarium and CouchDB Jonathan Weiss @jweiss @scalarium Peritor GmbH

description

How and why Scalarium is using CouchDB to control and manage thousands of machines on Amazon EC2

Transcript of Scalarium and CouchDB

Page 1: Scalarium and CouchDB

Scalarium and CouchDB

Jonathan Weiss @jweiss

@scalarium

Peritor GmbH

Page 2: Scalarium and CouchDB

Scalarium.com

EC2 Cluster Management  Automatic & dynamic configuration over lifetime

of a cluster via Chef runs

  Self healing clusters

 Auto scaling clusters

 One click deployment

 One click cluster cloning

 Monitoring & alerting

  Logs & accounting

  Firewalls & backups

 Access & rights management

2

Page 3: Scalarium and CouchDB

Use case wooga.com

One of wooga’s Facebook games   1.5 million DAU (Daily Active Users)

  ~ 130 servers

  ~ 150.000 requests per minute on average

  Complex stack with different databases and replication

  Multiple deployments of the game on multiple clusters

3

Page 4: Scalarium and CouchDB

Scalarium.com

4 http://www.flickr.com/photos/av8pix/3391322123/

Page 5: Scalarium and CouchDB

Data

Rather static but important   Cluster configuration

  Server descriptions and current state

  Lifecycle events: setup, deploy, configure, shutdown

 Applications and deployment definitions

  EC2 assets like EBS, elastic IPs, SSH keys

5

Dynamic and non-critical  Accounting & events

 Monitoring and metering

Page 6: Scalarium and CouchDB

Data

Rather static but important

6

Dynamic and non-critical

Page 7: Scalarium and CouchDB

Why CouchDB?

 High Availability

 Easy Replication

 Clustering

 Robustness

 Short Recovery Time

 Jan Lehnardt

7

Page 8: Scalarium and CouchDB

Architecture

8

Page 9: Scalarium and CouchDB

Architecture

9

Page 10: Scalarium and CouchDB

Interaction

10

Page 11: Scalarium and CouchDB

SimplyStored

Ruby library with ActiveRecord inspired capabilities  Models

 Associations Generates map & reduce

  Validations

  Callbacks

 Dynamic finders

  S3 attachments

  Paranoid delete

http://github.com/peritor/simply_stored

11

Page 12: Scalarium and CouchDB

SimplyStored

12

Page 13: Scalarium and CouchDB

SimplyStored

13

Page 14: Scalarium and CouchDB

Conflict & Resolution

14

Page 15: Scalarium and CouchDB

Conflict & Resolution

Re-load and retry: Automatically done by SimplyStored

Discard and report: Internal report

15

Page 16: Scalarium and CouchDB

RockingChair

In-memory CouchDB as a Ruby library   Just a big Hash

 Understands views generated by SimplyStored

  Speeds up your tests

  Tests can run in parallel

 Nice for debugging

http://github.com/jweiss/rocking_chair

16

Page 17: Scalarium and CouchDB

Operations

17

Page 18: Scalarium and CouchDB

Backup

Slaves in different EC2 availability zones and regions

Offsite copy of data and index files

18

Page 19: Scalarium and CouchDB

Hot Standby

19

Page 20: Scalarium and CouchDB

Cold Standby

20 http://www.flickr.com/photos/dnkemontoh/2680822579

Page 21: Scalarium and CouchDB

Keeping views fresh

 Cronjobs for crawling all design docs and calling all views

 On master & standby!

 Rollout new views without using them first

 And while we are there, compact views&dbs

21

Page 22: Scalarium and CouchDB

Performance

22

Page 23: Scalarium and CouchDB

I/O

CouchDB heavily depends on file system I/O   EBS RAIDs for better performance

 Different volumes for data and indices

  Be generous with RAM & CPU

23 http://www.flickr.com/photos/walkn/5471945439

Page 24: Scalarium and CouchDB

include_docs

 Nice feature to load related data in one go…but slow random I/O on read

 Emit the data you need to the view index

24

Page 25: Scalarium and CouchDB

Design Documents

 Maintained in a framework/model-layer

 Using md5 of content to decide if update needed

 Whenever one view definition changed, all views got recomputed

25

Page 26: Scalarium and CouchDB

Design Documents

Separate design document per view

Fine granular control  Update

 Delete

  Compact

26

Page 27: Scalarium and CouchDB

One DB to rule them all

27

Page 28: Scalarium and CouchDB

Separate DBs

28

Page 29: Scalarium and CouchDB

Wishlist

 Build-in caching

 include_docs to load from index

 Improved performance of building views

 Build-in solution for

automatic sharding

 Automatic compaction

 Metrics & monitoring

29

Page 30: Scalarium and CouchDB

Couchbase 2.0

30

Page 31: Scalarium and CouchDB

Q&A

Talk to us if you want to use Scalarium 3 month for free

@scalarium

31