Getting started with Riak in the Cloud

55
Getting started with Riak in the Cloud

description

Given at RICON 2012

Transcript of Getting started with Riak in the Cloud

Page 1: Getting started with Riak in the Cloud

Getting started with Riak in the Cloud

Page 2: Getting started with Riak in the Cloud

I work with Code!

I work with Data!

Michael Brodhead Ines Sombra@RandomMood@mojinations

Page 3: Getting started with Riak in the Cloud
Page 4: Getting started with Riak in the Cloud

Agenda

Application layer

Database layer

Page 5: Getting started with Riak in the Cloud

A tale of 2 apps

•One brand new (no code written)

•One in production running MySQL

Page 6: Getting started with Riak in the Cloud
Page 7: Getting started with Riak in the Cloud
Page 8: Getting started with Riak in the Cloud
Page 9: Getting started with Riak in the Cloud

MultipleRegions

Page 10: Getting started with Riak in the Cloud

MultipleClouds

Page 11: Getting started with Riak in the Cloud

11

Page 12: Getting started with Riak in the Cloud

The Librariesriak-client

• simple Ruby access to Riak's HTTP & protocol buffer APIs

Page 13: Getting started with Riak in the Cloud

The Libraries

Ripple

• Higher level, ORM interface

• ActiveModel based buffer APIs

Page 14: Getting started with Riak in the Cloud

Simplicity

Page 15: Getting started with Riak in the Cloud
Page 16: Getting started with Riak in the Cloud

The Librariesdm-riak

• Already using DataMapper

• Hoping for trivial switchover

Page 17: Getting started with Riak in the Cloud

The LibrariesRiak Shim

• database.yml

• Bucket naming

• Hides JSON

• 2i

Page 18: Getting started with Riak in the Cloud

Challenges

•Unit tests

•Data migration

•Deployment

Page 19: Getting started with Riak in the Cloud

Testing

Page 20: Getting started with Riak in the Cloud

Testing

Page 21: Getting started with Riak in the Cloud

Deployment

Page 22: Getting started with Riak in the Cloud

Use your app logic

Page 23: Getting started with Riak in the Cloud

How do we get here?

Page 24: Getting started with Riak in the Cloud

... but we have no hardware

“We need a Riak cluster”

(@mojinations circa 3 months ago)

Page 25: Getting started with Riak in the Cloud

Let’s do it!

Page 26: Getting started with Riak in the Cloud

Why Riak Product?

• Linearly Scalable

• Fault-tolerant

•Ops friendly

• Product lacks HA options

Page 27: Getting started with Riak in the Cloud

Riak @ Engine Yard• We’ll use it first

• No custom Chef

• Provisioning, configuration, monitoring, & backups

Page 28: Getting started with Riak in the Cloud

Your Choices

• Number of nodes

• Instance type

• Data location

• Backend type

You are trying to create a Riak cluster. Do you need any help?

Page 29: Getting started with Riak in the Cloud
Page 30: Getting started with Riak in the Cloud

AWS OpsThe Riak on AWS slide

Page 31: Getting started with Riak in the Cloud

Instances & I/O

• Riak’s I/O patterns

• Small blobs from many places on disk

• EBS best at bulk reads & writes

Page 32: Getting started with Riak in the Cloud

Instance types

•m1.large & m1.xlarge

• EBS-optimized

•Consider PIOPS

•High I/O Quadruple XL (hi1.4xlarge) - SSDs!

NEW!

NEW!

NEW!

Page 33: Getting started with Riak in the Cloud

More instances to compensate for the performance variability of virtualized resources

Prepare Yourself

Page 34: Getting started with Riak in the Cloud

Cluster Sizes

• 5 nodes or moreBest performance & growth

• Scales linearly

•Don’t be stingy

Page 35: Getting started with Riak in the Cloud

Ring Size

•Change default value!

•Cannot be reset

• Ring size: 2568/64 vnodes per node

•Don’t go above 512

Page 36: Getting started with Riak in the Cloud

Provisioning

App

haproxy

MyRiakCluster: node-0

MyRiakCluster: node-1

MyRiakCluster: node-2

MyRiakCluster: node-3

MyRiakCluster: node-4

Riak Cluster

HTTPor

ProtobuffApp

haproxy

App

haproxy

Page 37: Getting started with Riak in the Cloud

Disable Swap• Riak process pages should

not hit swap

• Swap usage can result in unresponsive server

• Let the kernel kill it

Page 38: Getting started with Riak in the Cloud

Mount & Scheduler

•mount with noatime flag

•Use deadline scheduler on EBS cat /sys/block/xvdj1/queue/schedulernoop [deadline] cfq

echo deadline > /sys/block/xvdj1/queue/scheduler

Page 39: Getting started with Riak in the Cloud

Linux Filesystems

• xfs, ext3

• ext4

• barrier = 0

• data = writeback

• ZFS not recommended

Page 40: Getting started with Riak in the Cloud

Backend choices

•Bitcask*

•help mitigate EBS

• LevelDB

•MemoryCan be

changed and

optimized!

Page 41: Getting started with Riak in the Cloud

Kernel Optimizations

• /etc/sysctl.conf vm.swappiness = 0net.core.somaxconn= 4000net.ipv4.tcp_timestamps = 0net.ipv4.tcp_window_scaling = 1net.ipv4.tcp_max_syn_backlog = 40000net.ipv4.tcp_sack = 1net.ipv4.tcp_fin_timeout = 15net.ipv4.tcp_keepalive_intvl = 30net.ipv4.tcp_tw_reuse = 1

http://wiki.basho.com/Linux-Performance-Tuning.html

Page 43: Getting started with Riak in the Cloud

Backups

• Backup both the ring and data directories

• Integrate with EY tools

• scp or rsync data directory

• EBS snapshots

Page 44: Getting started with Riak in the Cloud

Scaling Riak

•Vertical

•Horizontal

• reduces node load

• batch is better

riak-admin cluster replace <old> <new>

Page 45: Getting started with Riak in the Cloud

Benchmarks

Page 46: Getting started with Riak in the Cloud

Tests

• 5-node cluster / 5 hours

• 50 concurrent connections

• gets 10 /puts 5 /deletes 1

• Bitcask backend

• Protobuffs protocol

Page 47: Getting started with Riak in the Cloud

Medium - PIOPS 500

Page 48: Getting started with Riak in the Cloud

Medium - PIOPS 1K

Page 49: Getting started with Riak in the Cloud

Medium - Ephemeral

FAIL!

Page 50: Getting started with Riak in the Cloud

XL - EBS

Page 51: Getting started with Riak in the Cloud

XL -PIOPS 500

Page 52: Getting started with Riak in the Cloud

4XL - EBS

Page 53: Getting started with Riak in the Cloud

4XL - PIOPS 1k

Page 54: Getting started with Riak in the Cloud

What’s next?

Page 55: Getting started with Riak in the Cloud