Riak at Engine Yard Cloud

51
Riak in the Cloud Getting Started with Big Nerd Ranch

description

Given at Big Nerd Ranch in Atlanta.

Transcript of Riak at Engine Yard Cloud

Page 1: Riak at Engine Yard Cloud

Riak in the Cloud

Getting Started with

Big Nerd Ranch

Page 2: Riak at Engine Yard Cloud

Ines Sombra

@RandomMood

About Me

Page 3: Riak at Engine Yard Cloud

About Us

Our Agenda

The Problem

The Solution

Our Customers

Page 4: Riak at Engine Yard Cloud

Engine Yard

Page 5: Riak at Engine Yard Cloud

About US100% Cloud Based

Critical services MUST be up 24/7/365

CloudsRegions

StacksSupport

HA

DR

Page 7: Riak at Engine Yard Cloud

An APPLICATION

App

App

App

DB Master

DB Replica

us-east-1a

us-east-1b

Page 8: Riak at Engine Yard Cloud

http://www.flickr.com/photos/brandongrasley/8227882239/

Then AWS Crashed

Page 9: Riak at Engine Yard Cloud

Our App AFTER

App

App

App

DB Master

DB Replica

us-east-1a

us-east-1b

X

Page 10: Riak at Engine Yard Cloud

!

This sucked, A LOTTime to strengthen our HA/DR Story

Customers and us need to be up all the time!

$

Page 11: Riak at Engine Yard Cloud

Relational

Document

Key/Value

Column

Data Models Consistency Partitions

Our Research

Are ACID properties really needed?

Consistency

Availability

Page 12: Riak at Engine Yard Cloud

Relational Model

Impedance Mismatch

Page 13: Riak at Engine Yard Cloud

Memory data-structure

Impedance Mismatch

Page 14: Riak at Engine Yard Cloud

We needed a fault tolerant and highly available (clustered)

datastore

Page 15: Riak at Engine Yard Cloud

Linearly scalable

Fault-tolerant

Finally provide HA/DR solution

OSS, Dynamo-based, distributed K/V store Hello RIAK!

Page 16: Riak at Engine Yard Cloud

Riak’s Use CasesApplication Type Key Value

Session User/Session id Data

Advertising Campaign id Data

Logs Date Log file

Content title, integer text, json, xml, media..

Page 17: Riak at Engine Yard Cloud

When is Riak a good fit

When availability is more important than consistency

When data can be modeled as keys/values

When the problem fits

Page 18: Riak at Engine Yard Cloud

Riak is OPS FRIENDLY

node1.2.1

node1.2.1

node1.2.1

node1.2.1

node1.2.1

Growth

Reduction

Upgrades

Failuresnode1.3.0

X

Page 19: Riak at Engine Yard Cloud

World’s most famous slide

Page 20: Riak at Engine Yard Cloud

Riak is SO MUCH MORE

Consistent HashingHinted Handoff

Active Anti EntropyTuneable consistencyN | W | R

Page 21: Riak at Engine Yard Cloud

OUR APP AFTER

App

App

node1.3.0

node1.3.0

node1.3.0

node1.3.0

node1.3.0

App

Page 22: Riak at Engine Yard Cloud

We need a Riak Cluster but we have

no hardware

Page 23: Riak at Engine Yard Cloud

RIAK In the Wild

18th and Harrison, San Francisco, CA

Page 24: Riak at Engine Yard Cloud

Let’s build A PRODUCT

http://www.flickr.com/photos/worldbank/8261699153/

Page 25: Riak at Engine Yard Cloud

1

2

3

4

Number of Nodes

Your CHOICESYou are trying

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

Instance TypeData LocationBackend Type

Page 26: Riak at Engine Yard Cloud

What we GIVE YOU

Page 27: Riak at Engine Yard Cloud

Our SUPPORT

X2

Page 28: Riak at Engine Yard Cloud

What you OPS to know

HOWTO

Page 29: Riak at Engine Yard Cloud

Prepare Yourself

More instances to compensate for the

performance variability of virtualized resources

Page 30: Riak at Engine Yard Cloud

^ m1.large & m1.xlarge

EBS-optimized or PIOPs

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

Choosing INSTANCES

Page 31: Riak at Engine Yard Cloud

5 nodes or moreBest performance & growth

Scales linearly

Don’t be stingy

Cluster Sizes

Page 32: Riak at Engine Yard Cloud

Change DefaultCANNOT BE RESET

(8-64 vnodes per node)

Ring SIZE

Ring Size at 256

DONT GO OVER 512

Page 33: Riak at Engine Yard Cloud

Our 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

Riak Cluster

Page 34: Riak at Engine Yard Cloud

^ Riak process pages should not hit swap

Swap usage can result in unresponsive server

Let the kernel kill it

Disable SWAP

Page 35: Riak at Engine Yard Cloud

^ Mount with noatime flag

Use deadline scheduler on EBS

Mount & SCHEDULER

cat /sys/block/xvdj1/queue/schedulernoop [deadline] cfq

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

Page 36: Riak at Engine Yard Cloud

^ xfs, ext3

ext4 barrier = 0 data = writeback

ZFS not recommended

Linux FILESYSTEMS

Page 37: Riak at Engine Yard Cloud

^ Backup both the ring and data directories

scp or rsync data dir

EBS snapshots

Backup STRATEGY

Page 38: Riak at Engine Yard Cloud

Monitoring STRATEGY

Stats Interface

riak-admin status

Collectd

Nagios

Page 39: Riak at Engine Yard Cloud

^ Vertical

Scaling RIAK

riak-admin cluster replace <old> <new>

^ Horizontalriak-admin cluster add <new>

Page 40: Riak at Engine Yard Cloud

How we SCALE RIAK

Page 41: Riak at Engine Yard Cloud

+ PostgreSQLRIAK

Hybrid Solutions FTW

+ FTS Engine*RIAK

+ RedisRIAK

Page 42: Riak at Engine Yard Cloud

Try OUR RIAK

Page 43: Riak at Engine Yard Cloud

How difficult IS IT?

Page 44: Riak at Engine Yard Cloud

A few thoughts

Finally!

Page 45: Riak at Engine Yard Cloud

Pick the right tool for the job

Apps & Services can have multiple databases

Polyglot PERSISTENCE

Page 46: Riak at Engine Yard Cloud

On SOAMy super nice e-commerce site

Shopping Cart & Session Data

Completed Orders

Inventory and Item Pricing

Recommendations Engine

Session Storage serviceK/V Store

Order Persistence

serviceDocument

Store

Inventory & Price service

RDBMS

Nodes and relations service

Graph Store

NoSQL Distilled: Fowler & Sadalage

Page 47: Riak at Engine Yard Cloud

Don’t optimize too quickly

Take time to understand your problem

Complexity increases with more databases

We RECOMMEND

Page 48: Riak at Engine Yard Cloud

Do KEEP IN MIND

Relational Document Store!=

Different paradigms are different

Page 49: Riak at Engine Yard Cloud

Give me MOAR!

Whatever

Page 50: Riak at Engine Yard Cloud

Little Riak Book (https://github.com/coderoshi/little_riak_book/)

docs.basho.comblog.engineyard.comnosql.mypopescu.com

Great RESOURCES

Page 51: Riak at Engine Yard Cloud

Questions?