18
Databases - Which, Why and Usage Tips Avner Cohen Infrastructure & Architecture @ Fiverr Birdwatcher @ Sewage Pools @avnerner AvnerCohen @ Github

Databases which, why and usage tips

Embed Size (px)

Citation preview

Page 1: Databases which, why and usage tips

Databases - Which, Why and Usage Tips

Avner Cohen Infrastructure & Architecture @ Fiverr Birdwatcher @ Sewage Pools

@avnerner

AvnerCohen @ Github

Page 2: Databases which, why and usage tips

RDBMS

Relational Database Management System

Page 3: Databases which, why and usage tips

NoSQL Not Only SQL - but mainly, not RDBMS

Page 4: Databases which, why and usage tips

Acronyms

CAP theorem“.. it is impossible for a distributed computer system to simultaneously provide all three of the following guarantees Consistency, Availability, Partition tolerance “ - Eric Brewer, 1998

ACID“.. a set of properties that guarantee that database transactions are processed reliably - Atomicity - Consistency - Isolation - Durability”

BASE“.. an alternative to ACID - Basic Availability, Soft-state, Eventual consistency “

Page 5: Databases which, why and usage tips

NewSQL

Solving scalability without compromising on ACIDHOW?

.. CAP Theorem isn’t simply a case of consistency, availability, partition tolerance. Pick two…

Page 6: Databases which, why and usage tips

Call me Maybeby Kyle Kingsbury• “Breaking distributed systems so you

don't have to.”• https://github.com/aphyr/jepsen• http://aphyr.com/tags/jepsen

Page 7: Databases which, why and usage tips
Page 8: Databases which, why and usage tips

Now What ?

Page 9: Databases which, why and usage tips

@ Fiverr

Page 10: Databases which, why and usage tips

MySQLProperties• Traditional RDBMS• Owns by Oracle and widely used• Open source• Pluggable storage engines (MyISAM, InnoDB, Federated,

more)Stuff etc.•Multiple forks (MariaDB, PerconaDB, WebScaleSQL)•Master/Slave setup and pitfalls (Octopus, DBCharmer, MaxScale, Mysql Proxy)

•Master/Master - Galera Cluster•Shlomi Noach’s http://code.openark.org/forge/openark-kit, https://github.com/outbrain/propagator

•Rails 4 default - strict: false

Page 11: Databases which, why and usage tips

MongoDBProperties• Document based

• BSON (Binary JSON)• Open source• Indices - primary and secondaries• No JoinsStuff etc.•Console - https://github.com/TylerBrock/mongo-hacker•UI - Mongohub (up to date fork - https://github.com/jeromelebel/MongoHub-Mac)

•Eventual consistent, configurable, query level•Gems: Moped, Mongoid, mongo-driver, BSON•TokuMX- https://github.com/Tokutek/mongo•_id can (and should) be overwritten.

Page 12: Databases which, why and usage tips

PostgreSQLProperties• Traditional RDBMS• (Still) Open Source• Semi structured (JSON) data

Stuff etc.• The Rails goto nowadays.• “..Some people use <NoSQL solution> Just for the

schemaless feature..”

Page 13: Databases which, why and usage tips

RedisProperties• REmote DIctionary Server• Data Structure server, single threaded• In memory but also persisted to disk• Master/Slave (Cluster in 4yo beta, but is coming.)• One man showStuff etc.• Know your date-types (Sorted Sets, Arrays, etc.)• Redis-faina - https://github.com/facebookarchive/redis-

faina• BGSAVE forking issues• HyperLogLog - http://antirez.com/news/75• Do not kill -9 a diskeless master… - https://stripe.com/blog/

game-day-exercises-at-stripe (a.k.a the stripe-redis drama)

Page 14: Databases which, why and usage tips

MemcachedProperties• As basic as it gets Key Value• in-memory• client side sharding• Efficient in large data blocks

Stuff etc.• Dalli• Compression• MasterCacheKey• Name Spacing

Page 15: Databases which, why and usage tips

CouchbaseProperties• Document store• Memcached layer out of the box• Views• Operation tooling

Stuff etc.• Querying is a PITA• “Thick” clients• LivePerson and Viber

Page 16: Databases which, why and usage tips

Apache SolrProperties• Search Server• Server on top of Lucene• Fuzzy search• Vibrant and productive community

Stuff etc.• Query slave, index master• Extended DisMax• Indexing solutions• Micro service

Page 17: Databases which, why and usage tips

Wrapping up

• Polyglot Persistence - Martin Fowler• Use as a micro services enabler• Learn from Kyle - Embrace Failure