KEMBAR78
Databases which, why and usage tips | PDF
Databases - 
Which, Why and Usage Tips 
Avner Cohen 
Infrastructure & Architecture @ Fiverr 
Birdwatcher @ Sewage Pools 
@avnerner 
AvnerCohen @ Github
RDBMS 
Relational Database Management System
NoSQL Not Only SQL - but mainly, not RDBMS
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 “
NewSQL 
Solving scalability without compromising on ACID 
HOW? 
.. CAP Theorem isn’t simply a case of consistency, 
availability, partition tolerance. Pick two…
Call me Maybe 
by Kyle Kingsbury 
• “Breaking distributed systems so you 
don't have to.” 
• https://github.com/aphyr/jepsen 
• http://aphyr.com/tags/jepsen
Now What ?
@ Fiverr
MySQL 
Properties 
• 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
MongoDB 
Properties 
• Document based 
• BSON (Binary JSON) 
• Open source 
• Indices - primary and secondaries 
• No Joins 
Stuff 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.
PostgreSQL 
Properties 
• 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..”
Redis 
Properties 
• 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 show 
Stuff 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)
Memcached 
Properties 
• As basic as it gets Key Value 
• in-memory 
• client side sharding 
• Efficient in large data blocks 
Stuff etc. 
• Dalli 
• Compression 
• MasterCacheKey 
• Name Spacing
Couchbase 
Properties 
• Document store 
• Memcached layer out of the box 
• Views 
• Operation tooling 
Stuff etc. 
• Querying is a PITA 
• “Thick” clients 
• LivePerson and Viber
Apache Solr 
Properties 
• 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
Wrapping up 
• Polyglot Persistence - Martin Fowler 
• Use as a micro services enabler 
• Learn from Kyle - Embrace Failure
Thank You. 
@avnerner 
AvnerCohen @ Github 
israbirding@gmail.com

Databases which, why and usage tips

  • 1.
    Databases - Which,Why and Usage Tips Avner Cohen Infrastructure & Architecture @ Fiverr Birdwatcher @ Sewage Pools @avnerner AvnerCohen @ Github
  • 2.
    RDBMS Relational DatabaseManagement System
  • 3.
    NoSQL Not OnlySQL - but mainly, not RDBMS
  • 4.
    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 “
  • 5.
    NewSQL Solving scalabilitywithout compromising on ACID HOW? .. CAP Theorem isn’t simply a case of consistency, availability, partition tolerance. Pick two…
  • 6.
    Call me Maybe by Kyle Kingsbury • “Breaking distributed systems so you don't have to.” • https://github.com/aphyr/jepsen • http://aphyr.com/tags/jepsen
  • 8.
  • 9.
  • 10.
    MySQL Properties •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
  • 11.
    MongoDB Properties •Document based • BSON (Binary JSON) • Open source • Indices - primary and secondaries • No Joins Stuff 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.
  • 12.
    PostgreSQL Properties •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..”
  • 13.
    Redis Properties •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 show Stuff 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)
  • 14.
    Memcached Properties •As basic as it gets Key Value • in-memory • client side sharding • Efficient in large data blocks Stuff etc. • Dalli • Compression • MasterCacheKey • Name Spacing
  • 15.
    Couchbase Properties •Document store • Memcached layer out of the box • Views • Operation tooling Stuff etc. • Querying is a PITA • “Thick” clients • LivePerson and Viber
  • 16.
    Apache Solr Properties • 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
  • 17.
    Wrapping up •Polyglot Persistence - Martin Fowler • Use as a micro services enabler • Learn from Kyle - Embrace Failure
  • 18.
    Thank You. @avnerner AvnerCohen @ Github israbirding@gmail.com