SlideShare uma empresa Scribd logo
1 de 72
Baixar para ler offline
Polyglot Persistence
      Two Great Tastes
  That Taste Great Together!


                      John Wood
               john_p_wood@yahoo.com
                     @johnpwood
About Me
●   Software Developer at Interactive Mediums
●   Primarily work on a web application that allows
    our customers to engage and interact with their
    customers
●   Writing code for about 15 years
●   Tinkering with NoSQL for about 1.5 years
●   Have a NoSQL solution that has been running
    in production for a year
You Now Have A Choice
You Now Have A Choice
You Now Have A Choice
You Now Have A Choice
You Now Have A Choice
You Now Have A Choice
You Now Have A Choice
You Now Have A Choice
You Now Have A Choice
You Now Have A Choice
The RDBMS Is No Longer The
      Default Choice
The RDBMS Is No Longer The
           Default Choice
●   Can be very difficult to scale horizontally
●   Schemas can be difficult to maintain and
    migrate
●   For some applications, the data integrity
    features of the RDBMS are an unnecessary
    overhead
●   Data constraints and JOINs can be expensive
    at runtime
NoSQL Databases Have Stepped
  Up To Address These Issues
NoSQL Databases Have Stepped
      Up To Address These Issues

●   Schema-less
●   Little to no data integrity enforcement
●   Self-contained data
●   Eventually consistent
●   Easy to scale horizontally to add processing
    power and storage
But The RDBMS Is Far From Dead
But The RDBMS Is Far From Dead
●   Incredibly mature, and battle tested
●   Immediate and constant consistency
●   Integrity of data is enforced
●   Efficient use of storage space if data
    normalized properly
●   Supported by everyone and everything (tools,
    frameworks, libraries, etc)
●   Incredibly flexible and powerful query language
●   Help is plentiful and easy to find
Choice is good...right?
Decisions, Decisions...
You Don't Have to
     Choose
“You've got your chocolate in my peanut butter!”
Polyglot Persistence
pol●y●glot - Adjective
Knowing or using several languages
pol●y●glot - Adjective
  Knowing or using several languages



        per●sist●ence - Noun
The continued or prolonged existence of
              something
Polyglot Persistence
The continued or prolonged existence of
   something using several languages
Polyglot Persistence
The continued or prolonged existence of
   something using several languages
              databases
“Polyglot Persistence, like
  polyglot programming, is all
    about choosing the right
persistence option for the task at
   hand.” - Scott Leberknight,
         October, 2008


     http://www.nearinfinity.com/blogs/scott_leberknight/polyglot_persistence.html
Why On Earth Would
You Want To Do This?
CAP Theorem



  http://en.wikipedia.org/wiki/CAP_theorem
http://blog.nahurst.com/visual-guide-to-nosql-systems
Compromise
Consistency and
 Data Integrity
       +
 Scalability and
   Flexibility
Support A Wide Range
     of Storage
   Requirements
Get The Job Done
Faster, With Better
     Quality
DB Doesn't Just Stand For
       Database
Don't Swim Upstream
Possible Use Cases
Use A NoSQL Database
    For A Particular
  Application Feature
Use A NoSQL Database
  For Speedy Batch
      Processing
Use A NoSQL Database
For Distributed Logging
Use A NoSQL Database
   For Large Tables
Use A RDBMS For
    Reporting
Sounds Great!
What's The Catch?
Difficult For Data In
Different Databases To
        Interact
You Now Have To
Decide Where To Store
        Data
Increased Application
  And Deployment
     Complexity
Additional
Administrative
Responsibilities
Training
What Will This Do To
My Beautiful Code?
It's All About The Layers
class User < ActiveRecord::Base
end


class ContestEntry < CouchRest::ExtendedDocument
 property :entry_number
end
class User < ActiveRecord::Base
 def contest_entries
   ContestEntry.entries_for_user(self.id)
 end
end

class ContestEntry < CouchRest::ExtendedDocument
 property :entry_number
 property :user_id

 def self.entries_for_user(user_id)
  # Execute your view to fetch the contest entries
 end

 def user
  User.f nd_by_id(user_id)
       i
 end
end
Additional Options
    Available
So, Who Is Actually
    Doing This?
●   Primary MySQL database with a backup
●   A few very large tables, containing 5M – 30M
    rows each, and growing quickly
●   Increasing query execution time
●   Some pages on the web app were timing out
●   Increasing database migration time
●   Rigid schema of the RDBMS was preventing
    some planned features from moving forward
●   Brought in a consultant to help us optimize our
    MySQL setup
●   Optimized slow queries
●   Added some indexes
●   Offloaded some work to the backup database
●   Considered the use of summary tables for
    statistics
+
●   Migrated old data from large tables to CouchDB
●   Using CouchDB views to aggregate summary
    data
●   Data is imported and views are updated nightly
●   Queries for statistics now very fast
●   Using Lucene (via couchdb-lucene) for full text
    searching
●   Taking full advantage of CouchDBs schema-
    less nature in several new application features
It's Not All Rainbows And Unicorns
●   CouchDB databases and views can be very
    large on disk
●   Some queries could not be substituted with
    CouchDB views
●   Indexing tens of millions of documents for full
    text search with Lucene takes weeks
●   Development takes longer, as the map/reduce
    model requires additional thought and planning
●   Changing/Upgrading views in production not
    straightforward
                  http://www.couch.io/migrating-to-couchdb
http://twitter.com/about/opensource
●   Vertically and horizontally partitioned MySQL
●   Several layers of aggressive caching, all
    application managed
●   Schema changes impossible, resulting in the
    use of bitfields and piggyback tables
●   Hardware intensive
●   Error prone
●   Hitting MySQL limits
●   Already eventually consistent
HBase



FlockDB
●   Migrating from MySQL to Cassandra as their
    main online data store
●   Hadoop/HBase used for people search feature
●   FlockDB used to manage the social graph
●   Hadoop for analytics
●   “As with all NoSQL systems, strengths in
    different situations” - Kevin Weil, Analytics
    Lead, Twitter
             http://www.slideshare.net/kevinweil/nosql-at-twitter-nosql-eu-2010
●   Increased availability
●   The ability to support new features
●   The ability to analyze their massive amount of
    data in a reasonable amount of time




            http://www.slideshare.net/kevinweil/nosql-at-twitter-nosql-eu-2010
Right Tool For The Job
Thanks!
john_p_wood@yahoo.com
      @johnpwood

Mais conteúdo relacionado

Mais procurados

Mais procurados (20)

Apache hadoop technology : Beginners
Apache hadoop technology : BeginnersApache hadoop technology : Beginners
Apache hadoop technology : Beginners
 
The Importance of DataOps in a Multi-Cloud World
The Importance of DataOps in a Multi-Cloud WorldThe Importance of DataOps in a Multi-Cloud World
The Importance of DataOps in a Multi-Cloud World
 
Managed Feature Store for Machine Learning
Managed Feature Store for Machine LearningManaged Feature Store for Machine Learning
Managed Feature Store for Machine Learning
 
Apache Spark Core
Apache Spark CoreApache Spark Core
Apache Spark Core
 
Building a Modern Data Warehouse - Deep Dive on Amazon Redshift
Building a Modern Data Warehouse - Deep Dive on Amazon RedshiftBuilding a Modern Data Warehouse - Deep Dive on Amazon Redshift
Building a Modern Data Warehouse - Deep Dive on Amazon Redshift
 
DW Migration Webinar-March 2022.pptx
DW Migration Webinar-March 2022.pptxDW Migration Webinar-March 2022.pptx
DW Migration Webinar-March 2022.pptx
 
Floating on a RAFT: HBase Durability with Apache Ratis
Floating on a RAFT: HBase Durability with Apache RatisFloating on a RAFT: HBase Durability with Apache Ratis
Floating on a RAFT: HBase Durability with Apache Ratis
 
Oracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLONOracle RAC 19c and Later - Best Practices #OOWLON
Oracle RAC 19c and Later - Best Practices #OOWLON
 
SmartDB Office Hours: Connection Pool Sizing Concepts
SmartDB Office Hours: Connection Pool Sizing ConceptsSmartDB Office Hours: Connection Pool Sizing Concepts
SmartDB Office Hours: Connection Pool Sizing Concepts
 
YARN High Availability
YARN High AvailabilityYARN High Availability
YARN High Availability
 
SQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12cSQL Monitoring in Oracle Database 12c
SQL Monitoring in Oracle Database 12c
 
Architecting Snowflake for High Concurrency and High Performance
Architecting Snowflake for High Concurrency and High PerformanceArchitecting Snowflake for High Concurrency and High Performance
Architecting Snowflake for High Concurrency and High Performance
 
Enabling the Active Data Warehouse with Apache Kudu
Enabling the Active Data Warehouse with Apache KuduEnabling the Active Data Warehouse with Apache Kudu
Enabling the Active Data Warehouse with Apache Kudu
 
How to size up an Apache Cassandra cluster (Training)
How to size up an Apache Cassandra cluster (Training)How to size up an Apache Cassandra cluster (Training)
How to size up an Apache Cassandra cluster (Training)
 
Oracle GoldenGate
Oracle GoldenGate Oracle GoldenGate
Oracle GoldenGate
 
Moving Beyond Lambda Architectures with Apache Kudu
Moving Beyond Lambda Architectures with Apache KuduMoving Beyond Lambda Architectures with Apache Kudu
Moving Beyond Lambda Architectures with Apache Kudu
 
A glimpse of cassandra 4.0 features netflix
A glimpse of cassandra 4.0 features   netflixA glimpse of cassandra 4.0 features   netflix
A glimpse of cassandra 4.0 features netflix
 
Achieving observability-in-modern-applications
Achieving observability-in-modern-applicationsAchieving observability-in-modern-applications
Achieving observability-in-modern-applications
 
Oracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer IntroductionOracle Stream Analytics - Developer Introduction
Oracle Stream Analytics - Developer Introduction
 
Getting Started with Delta Lake on Databricks
Getting Started with Delta Lake on DatabricksGetting Started with Delta Lake on Databricks
Getting Started with Delta Lake on Databricks
 

Semelhante a Polyglot Persistence - Two Great Tastes That Taste Great Together

NoSQLDatabases
NoSQLDatabasesNoSQLDatabases
NoSQLDatabases
Adi Challa
 
Couch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applicationsCouch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applications
Ihor Malytskyi
 
Big Data Strategy for the Relational World
Big Data Strategy for the Relational World Big Data Strategy for the Relational World
Big Data Strategy for the Relational World
Andrew Brust
 
How To Tell if Your Business Needs NoSQL
How To Tell if Your Business Needs NoSQLHow To Tell if Your Business Needs NoSQL
How To Tell if Your Business Needs NoSQL
DataStax
 
Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)
Don Demcsak
 

Semelhante a Polyglot Persistence - Two Great Tastes That Taste Great Together (20)

NoSQLDatabases
NoSQLDatabasesNoSQLDatabases
NoSQLDatabases
 
Big data and polyglot solutions
Big data and polyglot solutionsBig data and polyglot solutions
Big data and polyglot solutions
 
BigData Hadoop
BigData Hadoop BigData Hadoop
BigData Hadoop
 
Introduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDBIntroduction to NoSQL and MongoDB
Introduction to NoSQL and MongoDB
 
Practical Design Patterns for Building Applications Resilient to Infrastructu...
Practical Design Patterns for Building Applications Resilient to Infrastructu...Practical Design Patterns for Building Applications Resilient to Infrastructu...
Practical Design Patterns for Building Applications Resilient to Infrastructu...
 
Why does Microsoft care about NoSQL, SQL and Polyglot Persistence?
Why does Microsoft care about NoSQL, SQL and Polyglot Persistence?Why does Microsoft care about NoSQL, SQL and Polyglot Persistence?
Why does Microsoft care about NoSQL, SQL and Polyglot Persistence?
 
Big data & frameworks: no book for you anymore
Big data & frameworks: no book for you anymoreBig data & frameworks: no book for you anymore
Big data & frameworks: no book for you anymore
 
Big data & frameworks: no book for you anymore.
Big data & frameworks: no book for you anymore.Big data & frameworks: no book for you anymore.
Big data & frameworks: no book for you anymore.
 
Getting Started with Big Data in the Cloud
Getting Started with Big Data in the CloudGetting Started with Big Data in the Cloud
Getting Started with Big Data in the Cloud
 
Hadoop Training Tutorial for Freshers
Hadoop Training Tutorial for FreshersHadoop Training Tutorial for Freshers
Hadoop Training Tutorial for Freshers
 
Introduction to NoSQL
Introduction to NoSQLIntroduction to NoSQL
Introduction to NoSQL
 
Couch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applicationsCouch DB/PouchDB approach for hybrid mobile applications
Couch DB/PouchDB approach for hybrid mobile applications
 
Architecting Your First Big Data Implementation
Architecting Your First Big Data ImplementationArchitecting Your First Big Data Implementation
Architecting Your First Big Data Implementation
 
Big Data Strategy for the Relational World
Big Data Strategy for the Relational World Big Data Strategy for the Relational World
Big Data Strategy for the Relational World
 
Moving data to the cloud BY CESAR ROJAS from Pivotal
Moving data to the cloud BY CESAR ROJAS from PivotalMoving data to the cloud BY CESAR ROJAS from Pivotal
Moving data to the cloud BY CESAR ROJAS from Pivotal
 
Proud to be polyglot
Proud to be polyglotProud to be polyglot
Proud to be polyglot
 
Quick dive into the big data pool without drowning - Demi Ben-Ari @ Panorays
Quick dive into the big data pool without drowning - Demi Ben-Ari @ PanoraysQuick dive into the big data pool without drowning - Demi Ben-Ari @ Panorays
Quick dive into the big data pool without drowning - Demi Ben-Ari @ Panorays
 
How To Tell if Your Business Needs NoSQL
How To Tell if Your Business Needs NoSQLHow To Tell if Your Business Needs NoSQL
How To Tell if Your Business Needs NoSQL
 
Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)Big Data (NJ SQL Server User Group)
Big Data (NJ SQL Server User Group)
 
Rails data migrations
Rails data migrationsRails data migrations
Rails data migrations
 

Último

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 

Último (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 

Polyglot Persistence - Two Great Tastes That Taste Great Together

  • 1. Polyglot Persistence Two Great Tastes That Taste Great Together! John Wood john_p_wood@yahoo.com @johnpwood
  • 2. About Me ● Software Developer at Interactive Mediums ● Primarily work on a web application that allows our customers to engage and interact with their customers ● Writing code for about 15 years ● Tinkering with NoSQL for about 1.5 years ● Have a NoSQL solution that has been running in production for a year
  • 3. You Now Have A Choice
  • 4. You Now Have A Choice
  • 5. You Now Have A Choice
  • 6. You Now Have A Choice
  • 7. You Now Have A Choice
  • 8. You Now Have A Choice
  • 9. You Now Have A Choice
  • 10. You Now Have A Choice
  • 11. You Now Have A Choice
  • 12. You Now Have A Choice
  • 13. The RDBMS Is No Longer The Default Choice
  • 14. The RDBMS Is No Longer The Default Choice ● Can be very difficult to scale horizontally ● Schemas can be difficult to maintain and migrate ● For some applications, the data integrity features of the RDBMS are an unnecessary overhead ● Data constraints and JOINs can be expensive at runtime
  • 15. NoSQL Databases Have Stepped Up To Address These Issues
  • 16. NoSQL Databases Have Stepped Up To Address These Issues ● Schema-less ● Little to no data integrity enforcement ● Self-contained data ● Eventually consistent ● Easy to scale horizontally to add processing power and storage
  • 17. But The RDBMS Is Far From Dead
  • 18. But The RDBMS Is Far From Dead ● Incredibly mature, and battle tested ● Immediate and constant consistency ● Integrity of data is enforced ● Efficient use of storage space if data normalized properly ● Supported by everyone and everything (tools, frameworks, libraries, etc) ● Incredibly flexible and powerful query language ● Help is plentiful and easy to find
  • 21. You Don't Have to Choose
  • 22. “You've got your chocolate in my peanut butter!”
  • 24. pol●y●glot - Adjective Knowing or using several languages
  • 25. pol●y●glot - Adjective Knowing or using several languages per●sist●ence - Noun The continued or prolonged existence of something
  • 26. Polyglot Persistence The continued or prolonged existence of something using several languages
  • 27. Polyglot Persistence The continued or prolonged existence of something using several languages databases
  • 28. “Polyglot Persistence, like polyglot programming, is all about choosing the right persistence option for the task at hand.” - Scott Leberknight, October, 2008 http://www.nearinfinity.com/blogs/scott_leberknight/polyglot_persistence.html
  • 29. Why On Earth Would You Want To Do This?
  • 30. CAP Theorem http://en.wikipedia.org/wiki/CAP_theorem
  • 33. Consistency and Data Integrity + Scalability and Flexibility
  • 34. Support A Wide Range of Storage Requirements
  • 35. Get The Job Done Faster, With Better Quality
  • 36. DB Doesn't Just Stand For Database
  • 39. Use A NoSQL Database For A Particular Application Feature
  • 40. Use A NoSQL Database For Speedy Batch Processing
  • 41. Use A NoSQL Database For Distributed Logging
  • 42. Use A NoSQL Database For Large Tables
  • 43. Use A RDBMS For Reporting
  • 45. Difficult For Data In Different Databases To Interact
  • 46. You Now Have To Decide Where To Store Data
  • 47. Increased Application And Deployment Complexity
  • 50.
  • 51. What Will This Do To My Beautiful Code?
  • 52. It's All About The Layers
  • 53. class User < ActiveRecord::Base end class ContestEntry < CouchRest::ExtendedDocument property :entry_number end
  • 54. class User < ActiveRecord::Base def contest_entries ContestEntry.entries_for_user(self.id) end end class ContestEntry < CouchRest::ExtendedDocument property :entry_number property :user_id def self.entries_for_user(user_id) # Execute your view to fetch the contest entries end def user User.f nd_by_id(user_id) i end end
  • 55. Additional Options Available
  • 56. So, Who Is Actually Doing This?
  • 57.
  • 58. Primary MySQL database with a backup ● A few very large tables, containing 5M – 30M rows each, and growing quickly ● Increasing query execution time ● Some pages on the web app were timing out ● Increasing database migration time ● Rigid schema of the RDBMS was preventing some planned features from moving forward
  • 59. Brought in a consultant to help us optimize our MySQL setup ● Optimized slow queries ● Added some indexes ● Offloaded some work to the backup database ● Considered the use of summary tables for statistics
  • 60. +
  • 61. Migrated old data from large tables to CouchDB ● Using CouchDB views to aggregate summary data ● Data is imported and views are updated nightly ● Queries for statistics now very fast ● Using Lucene (via couchdb-lucene) for full text searching ● Taking full advantage of CouchDBs schema- less nature in several new application features
  • 62. It's Not All Rainbows And Unicorns
  • 63. CouchDB databases and views can be very large on disk ● Some queries could not be substituted with CouchDB views ● Indexing tens of millions of documents for full text search with Lucene takes weeks ● Development takes longer, as the map/reduce model requires additional thought and planning ● Changing/Upgrading views in production not straightforward http://www.couch.io/migrating-to-couchdb
  • 64.
  • 66.
  • 67. Vertically and horizontally partitioned MySQL ● Several layers of aggressive caching, all application managed ● Schema changes impossible, resulting in the use of bitfields and piggyback tables ● Hardware intensive ● Error prone ● Hitting MySQL limits ● Already eventually consistent
  • 69. Migrating from MySQL to Cassandra as their main online data store ● Hadoop/HBase used for people search feature ● FlockDB used to manage the social graph ● Hadoop for analytics ● “As with all NoSQL systems, strengths in different situations” - Kevin Weil, Analytics Lead, Twitter http://www.slideshare.net/kevinweil/nosql-at-twitter-nosql-eu-2010
  • 70. Increased availability ● The ability to support new features ● The ability to analyze their massive amount of data in a reasonable amount of time http://www.slideshare.net/kevinweil/nosql-at-twitter-nosql-eu-2010
  • 71. Right Tool For The Job