I’ve outgrown my basic stack. Now what?

28
Hivereader.com I’ve outgrown my basic stack. Now what? Thoughts and feelings about growing with Django and NoSQL

description

Thoughts and feelings about growing with Django and NoSQL.

Transcript of I’ve outgrown my basic stack. Now what?

Page 1: I’ve outgrown my basic stack. Now what?

Hivereader.com

I’ve outgrown my basic stack. Now what?

Thoughts and feelings about growing with Django and NoSQL

Page 2: I’ve outgrown my basic stack. Now what?

Hivereader.com

Our common stack is built on:

Super awesome and fast (once you learn what knobs to turn).Lots of cool features and tools: pg_tune, pg_top, pg_bouncer

Django is a high-level Python Web framework that encourages rapid development and clean, pragmatic design.

In-memory key-value store for small chunks of data.Super simple and awesome

Page 3: I’ve outgrown my basic stack. Now what?

Hivereader.com

People are signing up and using your app/game/site/bread maker/whatever

Page 4: I’ve outgrown my basic stack. Now what?

Hivereader.com

hooray

Page 5: I’ve outgrown my basic stack. Now what?

Hivereader.com

But

Page 6: I’ve outgrown my basic stack. Now what?

Hivereader.com

Things get start to get slow

Page 7: I’ve outgrown my basic stack. Now what?

Hivereader.com

or worse

Page 8: I’ve outgrown my basic stack. Now what?

Hivereader.com

Single server

appapp

DBDB

otherother

Page 9: I’ve outgrown my basic stack. Now what?

Hivereader.com

Find your bottlenecks:

Unless your app is doing something crazyyou’re mostly abusing the DB

Add more caching or, better yet, smarter caching

Page 10: I’ve outgrown my basic stack. Now what?

Hivereader.com

Page 11: I’ve outgrown my basic stack. Now what?

Hivereader.com

pg_bouncer

Page 12: I’ve outgrown my basic stack. Now what?

Hivereader.com

Welcome to Postgres config filepg_tune is here to help*

*kind of

Page 13: I’ve outgrown my basic stack. Now what?

Hivereader.com

Still Growing?

Page 14: I’ve outgrown my basic stack. Now what?

Hivereader.com

appapp

DBDB

otherother

appapp

DBDB

appapp

DBDB

otherother

appapp

DBDB

otherother

Page 15: I’ve outgrown my basic stack. Now what?

Hivereader.com

Need a solution for lots of data that is growing quickly.

The solution needs to be targeted for my problem.

Page 16: I’ve outgrown my basic stack. Now what?

Hivereader.com

NoSQL to the rescue?

Page 17: I’ve outgrown my basic stack. Now what?

Hivereader.com

But wait, can Postgres handle this?

most likely

partitioningand

sharding

Can have lots of app code sometimes.What about when you outgrow your shard key

“Don’t shard until you have to” - every single talk I’ve seen

Slony?“master to multiple slaves” replication

Page 18: I’ve outgrown my basic stack. Now what?

Hivereader.com

Lots of options

+ tons more

Page 19: I’ve outgrown my basic stack. Now what?

Hivereader.com

Nearly all of them are based on 2 papers

Built on CAP theoremThe theorem began as a conjecture made by University of California, Berkeley computer scientist Eric Brewer at the 2000 Symposium on Principles of Distributed Computing.

In 2002, Seth Gilbert and Nancy Lynch of MIT published a formal proof of Brewer's conjecture, rendering it a theorem.

Page 20: I’ve outgrown my basic stack. Now what?

Hivereader.com

Which one?

Page 21: I’ve outgrown my basic stack. Now what?

Hivereader.com

Super fastAdvanced key-value storeThink of it as super memcached. With union math.All data must fit in ramIt is often referred to as a data structure serverKeys can contain strings, hashes, lists, sets and sorted setsNot a db solution but more of a helper.

This is now a part of our basic stack for most apps.

Page 22: I’ve outgrown my basic stack. Now what?

Hivereader.com

Document storeJSON-like documents with dynamic schemasAd-hoc queriesIndexingLoad-balancing MongoDB scales horizontally using sharding

MongoDB uses a readers-writer lock that allows concurrent reads access to a database but gives exclusive access to a single write operation.However, when a write lock exists, a single write operation holds the lock exclusively, and no other read or write operations may share the lock.

Global write lock*Uncompressed field namesSafe off by defaultJust google “mongo problems” or “moving off mongodb”

Page 23: I’ve outgrown my basic stack. Now what?

Hivereader.com

Uses pre-defined column family formatMap ReduceUsed by all people with with ‘big data’ problemsAmazing workhorse for data

You need a sizable clusterCluster setup can be difficult

/ hbase

I need to personally spend more time with this

Page 24: I’ve outgrown my basic stack. Now what?

Hivereader.com

JSON to store data, JavaScript for MapReduce and HTTP for an API. Views: embedded map/reduceMulti-master replication

BigCouch, couchbase, Membase?Kind of in a dev rut......but just pushed a new huge upgrade

Page 25: I’ve outgrown my basic stack. Now what?

Hivereader.com

Based hardcore on Amazon's Dynamo paperKey Value storeSuper good about failure, “no downtime”Map Reduce / Secondary IndexesBuilt-in full text searchLink walking

2 types of mapreduceJavascript - can be slow as hellErlang - super fast

Page 26: I’ve outgrown my basic stack. Now what?

Hivereader.com

Key value + row-oriented = column familyLinear scalability and fault-tolerance on commodity hardware or cloud infrastructureBuilt by Facebook for MessagesHas CQL3 - think SQL, kind ofBaked auto cluster AMISuper fast writesCompresses data that’s not accessed a lotCan tie in to Hadoop for big map reduce

Page 27: I’ve outgrown my basic stack. Now what?

Hivereader.com

So now what?

Page 28: I’ve outgrown my basic stack. Now what?

Hivereader.com

Things to think about:

Is eventual consistency ok for you?Do you know your queries you need right now?

Is your data complicated or simple?How fast does it grow?

How long do you want that data to hang around?Really think about trade offs.

Every system has its good and badThere is no “winner”, so stop searching “which is best”

Think about which fits your use case

http://kkovacs.eu/cassandra-vs-mongodb-vs-couchdb-vs-redishttp://docs.basho.com/riak/1.2.1/references/appendices/comparisons/

Tons of links out there, just make sure they are relatively new