Top Banner
Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012 Monday, April 2, 12
28

Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Apr 09, 2018

Download

Documents

lytuong
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Building Cloud Services with RiakAndy Gross, @argv0Principal Architect, Basho TechnologiesErlang Factory SF 2012

Monday, April 2, 12

Page 2: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

What is a cloud service?

Web scale (seriously)

highly available

globally distributed

horizontally scalable

operationally simple

Monday, April 2, 12

Page 3: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Riak is Web Scale

Web scale (seriously)

highly available

globally distributed

horizontally scalable

operationally simple

Monday, April 2, 12

Page 4: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

NoSQL Complexity

Quorum controls: R, W, DW, PW, PR

Backend choices

Unfamiliar query model

Client libraries sometimes immature

Difficult to sell!

Monday, April 2, 12

Page 5: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Use Riak as foundation for simpler, “vertical” services (like cloud storage).

Monday, April 2, 12

Page 6: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Vertical Services

Abstract away NoSQL complexity

Provide simpler APIs

Have fewer configuration knobs

Have existing client libraries (sometimes)

Easier to sell!

Monday, April 2, 12

Page 7: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Riak Service Patterns

Riak Core Application

Stateless Proxy

Clustered Proxy

Monday, April 2, 12

Page 8: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Riak Extension Points

foo_vnode foo_ring|node_watcher

foo_db

foo_fsm foo_consolefoo_api

Riak Core

commit hooks custom kv backends

custom hash functions

Monday, April 2, 12

Page 9: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Riak Core Application

Usually consists of a custom vnode implementation and client API

Usually requires FSM for coordination with vnodes

Example:

https://github.com/jbrisbin/misultin-riak-core-vnode-dispatcher

Monday, April 2, 12

Page 10: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Stateless Proxy

Implemented as client of Riak KV

Deployed in separate VM

Uses Riak KV for all state storage

Proxies have no knowledge of each other

Scale independently from Riak

Monday, April 2, 12

Page 11: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Clustered Proxy

Use Riak Core at proxy layer for:

clustering

load balancing

distribution of proxy state

Monday, April 2, 12

Page 12: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Example:

Monday, April 2, 12

Page 13: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Riak CS

Announced on Tuesday

S3-compatible cloud storage backed by Riak

Follows “Stateless Proxy” pattern

Riak CS

Riak CS

Riak CS

RiakEDS

RiakEDS

RiakEDS

Monday, April 2, 12

Page 14: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Riak CS Overview

Implements S3 API via webmachine

Large files come in through API, 1+ Riak Objects written:

manifest: file metadata

chunks: statically sized chunks of large file

Monday, April 2, 12

Page 15: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

What worked well?

Monday, April 2, 12

Page 16: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Riak KV, Riak Core!

No code modifications required to build Riak CS

Resulting service inherits all of Riak’s webscale

Monday, April 2, 12

Page 17: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Tools

Erlang

Rebar

Quickcheck

Webmachine

Other Basho Open Source projects

Monday, April 2, 12

Page 18: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Process

Started as a prototype

Iterated quickly with a beta customer

Shipped frequently

Small, close team, grown slowly

Monday, April 2, 12

Page 19: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

What sucked?

Monday, April 2, 12

Page 20: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Connection Pooling

Just as hard as caching and naming

# incoming connections > # connection capacity of cluster

Started with naive approach

Outsourced to proxy software

Wrote proper connection pool

Monday, April 2, 12

Page 21: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Conflict Resolution Is Hard

Implementation of conflict-handling code can be very tricky

Required for high availability

CRDTs may help

QuickCheck saves the day, as always

Monday, April 2, 12

Page 22: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Lack Of Strong Consistency

Some S3 operations need to be atomic

Riak can’t do this

Implemented a stopgap solution with less-than-ideal availability properties

Monday, April 2, 12

Page 23: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Customer Environments

Everything besides Riak and Riak CS

Software != Service

Planning

Provisioning

Deployment

Monitoring

Monday, April 2, 12

Page 24: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

What may suck soon?

Monday, April 2, 12

Page 25: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Large Erlang Clusters

~150 works well in Riak deployments

Not sure how much further we can go

Approaches:

shard among many Riak clusters

investigate new distribution protocol

Monday, April 2, 12

Page 26: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Storage Costs

3x replication per datacenter gets expensive

Erasure coding is a possibility

Smarter global replication

notion of “home cluster” with 3 copies, others hav e 1 or 2

Monday, April 2, 12

Page 27: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Conclusions

Riak makes a perfect foundation for large scale internet services

Basho will make more of these

Lots of work to do on the environments riak/riak cs runs in

Monday, April 2, 12

Page 28: Building Cloud Services with Riak - erlang-factory.com€¦ · Building Cloud Services with Riak Andy Gross, @argv0 Principal Architect, Basho Technologies Erlang Factory SF 2012

Questions?

Monday, April 2, 12