Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

MinneBar 2013 - Scaling with Cassandra


Published on

NativeX (formerly W3i) recently transitioned a large portion of their backend infrastructure from MS SQL Server to Apache Cassandra. Today, its Cassandra cluster backs its mobile advertising network supporting over 10 million daily active users producing over 10,000 transactions per second with an average database request latency of under 2 milliseconds. Going from relational to noSQL required NativeX's engineers to re-train, re-tool and re-think the way it architects applications and infrastructure. Learn why Cassandra was selected as a replacement, what challenges were encountered along the way, and what architecture and infrastructure were involved in the implementation.

Published in: Technology
  • Be the first to comment

  • Be the first to like this

MinneBar 2013 - Scaling with Cassandra

  1. 1. Jeff Bollinger – CTO - @jbollingerJeff Smoley – Infrastructure ArchitectScaling With Cassandra
  2. 2. About NativeXThe BackstoryWhy CassandraCassandra OverviewNativeX Cassandra Implementation / MetricsWhat we LearnedAgenda
  3. 3. Formerly W3iMarketing technology platformthat enables developers to buildsuccessful businesses aroundtheir apps.NativeX
  4. 4. Over 620M unique devices on our networkOver 500 apps in network> 100M Monthly Active Users100 GB of data ingest per weekVanity Metrics
  5. 5. A growing mobile advertising networkBackstory01234562011 Q4 2012 Q1 2012 Q2 2012 Q3 2012 Q4 2013 Q1BillionsAPI Requests
  6. 6. Infrastructure Intensive Model0246810120 1 2 3 4 5 6 7 8 9 10 11 12MillionsSession Calls by Week After User AcquiredLifetime of user
  7. 7. Microsoft SQL Server2 Node Cluster (failover)12 cores / node192 GB of / nodeCompellent SAN172 Disk (SSD,FC,SATA)Scale Up Architecture
  8. 8. ConsistencyPartitionToleranceAvailabilityCAP TheoremSQL Server, MySQLCassandraMongoDB
  9. 9. Scale•Horizontal•Incrementalcost structureResiliency•No single pointof failure•GeographicallydistributedObjectives
  10. 10. Web Application TierDatabase TierWhat Needed to ScaleWeb Application Tier is already a server farm that can scalehorizontally through our VMWare environment.Database Tier was one giant monolithic Microsoft SQLServer machine.
  11. 11. Stands for Not Only SQLThe NoSQL movement is not about silver bullets andblack boxes.It’s about understanding problems and focusing onsolutions.It’s about using the right tool for the right problem.What is NoSQL?
  12. 12. Selecting CassandraDB Distributed Maturity High Availability Style Documentation Native Language Drivers PopularityMongoDB Yes Medium Yes Document - NoSQL Excellent Major Languages HighVoltDB Yes Low Yes RDBMS - SQL Good Major Languages LowMySQL Cluster Yes High Yes RDBMS - SQL & Key/Value Excellent Major Languages MediumMySQL ScaleDB Yes Low Yes RDBMS - SQL Good Major Languages LowCassandra Yes Medium Yes Key/Value - Column Family Excellent Major; Poor .Net HighCouchDB No Medium Yes Document - NoSQL ? No - REST only MediumRavenDB Yes? Low No Document - NoSQL Poor C#, JS, REST MediumCouchbase Yes Medium Yes Key/Value - Document Good Major Languages Medium*Disclaimer, this data was complied in spring of 2012 and my not reflect thecurrent state of each database system shown here. is a helpful site for discovering and learning aboutdifferent DB Systems.
  13. 13. Considered Multiple DB ProvidersMySQL ClusterRelational and very familiar.Has physical row limitations.MongoDBData modeling was simpler than C*.Not very clear if it had multi-cluster support.CassandraAt the very core it’s all about scalability and resiliency.Data modeling a little scary, limited .Net support.Top Choices
  14. 14. CassandraMulti-nodeMulti-clusterHighly AvailableDurableTunable ConsistencyShared Nothing
  15. 15. C* was not a replacement DB system, but an addition.C* solves a very specific problem (for us).Writing large volumes of data quickly.Reading very specific data out of a large record set.NoSQL solutions, like C*, are not meant to be areplacement for everything.You will make your lifer harder if you try!The same should be said about Relational Databases.They don’t solve every problem!C* at NativeX
  16. 16. We have three major classifications of data.ConfigurationActivity TrackingDevice HistoryData Classification
  17. 17. This data is relatively small in total size and is usedto operationally run our products. Examplesinclude:Mobile AppsOffersCampaignsRestrictionsQueue SettingsThis data is typically relational and thereforecontinues to be stored in MS SQL Server.Configuration Data
  18. 18. Data is stored inside of Column Families using nested Key/Value pairs.A Row Key maps to a collection of Columns.A Column Name (AKA Column Key) maps to a Column Value.The Column Name is stored along side the Value.A common strategy is to store JSON/XML in the Column Value.(Side note, if you’ve heard of Super Columns, forget about them, theyhurt more than they help)The Very Basics of C* Data Modeling
  19. 19. Raw tracking data for all activities used by the ETL process toproduce OLAP data on an hourly basis.Synonymous with Time Series, Event Series, or Logging data.Examples include:Running of Mobile AppsViewing OffersClicking on OffersReceiving RewardsActivity Tracking Data
  20. 20. Historical activities that each device has performed whilebeing part of NativeX’s network.Used for offer classification for a given device.Examples include:Clicking on OffersRunning Mobile AppsRedeeming RewardsDevice History Data
  21. 21. 12 NodesCisco UCS Blades12 Cores @ 2.0GHz with Hyper-threading64GB of Ram2 x 480GB Intel commodity SSDs in RAID 010.5 TB total, ~7 TB usableRed Hat LinuxHardware
  22. 22. We chose to use Enterprise hardware for the serversso that we would have support for them.However, our work load is very read heavy and 15Krpm rotational disks were a bottle neck.We chose to swap out the rotational for commoditySSDs. (Enterprise SSDs were 10x as expensive)We have limited support on the hardware because ofthis.Commodity Vs. Enterprise
  23. 23. 240 peak Writes per second per node2,880/sec cluster wide888 peak Reads per second per node10,656/sec cluster wide0.53 ms average Write Latency per request1.7 ms average Read Latency per requestAlmost 3 TB of data adding 1 TB a monthInternal C* Cluster Stats
  24. 24. MS SQLWrites 12 msReads 1.5 msC*Writes 3 msReads 4 msApplication Side Latencies
  25. 25. We think that in SQL Server, reads were fasterbecause most of the data sat in memory.We might be able to achieve lower latencies in C* ifwe gave each node just as much memory as our SQLServer.To counter act the increased latencies we usedcertain techniques like parallel reads using multi-threading in our web application.Can We Make Reads Faster?
  26. 26. There are still challenges with C*, like any complexsystem.More moving parts and things that need to stay insync.Misconfigurations can literally destroy your data.Certain config settings cannot be changed after youare live, such as the number of virtual Racks.Not all Roses
  27. 27. Get into production earlyData Import = RealityBreak down communication barriersUnderstanding your IO profile is really importantCassandra changes quickly, you need to keep upScalable systems like C* have a massive amount ofknobs, you need to know themLeverage cloud resources in working toward rightsizing your clusterLessons Learned
  28. 28. We’re hiring the MSP C* Meetup or @jbollingerSlide Deck