cassandra community webinar: mysql to cassandra - what i wish i'd known

27
Hindsight is 20/20: MySQL to Cassandra Michael Kjellman (@mkjellman) Barracuda Networks

Upload: datastax

Post on 26-Jan-2015

114 views

Category:

Technology


1 download

DESCRIPTION

A brief intro to how Barracuda Networks uses Cassandra and the ways in which they are replacing their MySQL infrastructure, with Cassandra. This presentation will include the lessons they've learned along the way during this migration. Speaker: Michael Kjellman, Software Engineer at Barracuda Networks Michael Kjellman is a Software Engineer, from San Francisco, working at Barracuda Networks. Michael works across multiple products, technologies, and languages. He primarily works on Barracuda's spam infrastructure and web filter classification data.

TRANSCRIPT

Page 1: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Hindsight is 20/20:MySQL to Cassandra

Michael Kjellman (@mkjellman)Barracuda Networks

Page 2: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

What I Do

• Build and maintain “real-time” Spam detection and Web Filter classification

• Java/Perl/C (and bits of everything else)• Author perlcassa (Perl C* client)• Frontend? Backend? Customer? Internal?

Broken RAID Card? Bad Disk? I touch it all.

Page 3: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Our C* Cluster

• In production for ~2 years since 0.8• Running 1.2.5 + minor patches• 24 nodes in 2 datacenters• (2) 2TB Hard Drives (no RAID)• (1) Small SSD for small hot CFs• 64GB of RAM• Puppet for management• Cobbler for deployment• Target max load at 600GB per node

Page 4: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

What is “real-time” exactly?

Page 5: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known
Page 6: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Our Rewrite by the NumbersCassandra Based

MySQL Based

Average Application Latency

2.41ms 5.0ms

Elements in Database

32,836,767 3,946,713

Elements Application Handles

32,836,767 314,974

Element Seen Prior to Tracking

1st request Various Thresholds

Datacenters 2 1

Average Latency of Automated Classification

3 seconds 8 minutes

Page 7: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Should you Rewrite?

• How To Survive a Ground-Up Rewrite Without Losing Your Sanity[1] – Joel Spolsky

• Past engineering decisions preventing implementation of new business requirements

• New threats smarter and more targeted

[1]http://onstartups.com/tabid/3339/bid/97052/How-To-Survive-a-Ground-Up-Rewrite-Without-Losing-Your-Sanity.aspx

Page 8: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Evolving Legacy Systems

• Even good developers can write sloppy code• Too much duct tape– Most layers applied around the database

Page 9: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Hitting the Reset Button

• Plan for continuous failure• Easily Scalable• No Single Point of Failure – that you know of • Many smaller boxes vs. one monolithic box

Page 10: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Whiteboard to Reality

• Get technical buy-in from all parties• Migrate and rewrite in stages– Business requirements forced hybrid period with

the old and new systems operated in parallel

Page 11: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known
Page 12: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Cassandra is Not…

1. Direct MySQL replacement2. Magic bullet to solve everything

Page 13: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Migrating

• Painful• Painful• Painful• Tons of rewriting• Tons of regressions• Did I say painful?

Page 14: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

So Why Migrate?

• C* is the best option for persistence tier• Business success motivation• Don’t let your database hold you back

Page 15: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Lessons Learned (the good)

• Carefully defining data model up front• Creating a flexible systems architecture that

adapts well to changes during implementation• Seriously – “Measure twice, cut once.”

Page 16: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Lessons Learned (the bad)

• Consider migration and delivery requirements from the very beginning

• Adjust expectations – didn’t expect relying on legacy systems for so long

• Make syncing data between systems a priority

Page 17: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Tips

1. Start with the queries2. Think differently regarding reads3. Syncing and migrating data4. Don’t use C* as a queue5. Estimate capacity6. Automate, Automate, Automate7. Some maintenance required

Page 18: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

1. Start with the Queries

• C* != “#dontneedtothinkaboutmyschema”• Counters and Composites• Optimize for use case– Don’t be afraid of writes. Storage is cheap. – Optimize to reduce the number of tombstones

Page 19: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

2. Think Differently Regarding Reads

• Do you really need all that data at once?• mysql> SELECT * FROM mysupercooltable WHERE foo = ‘bar’;– Slow, but eventually will work

• cqlsh> SELECT * FROM myreallybigcf WHERE foo = ‘bar’;– Won’t work. Expect RPC timeout exceptions on reads generally

after ~10,000 rows even with paging• Our solutions:

– ElasticSearch– Hadoop/Pig

Page 20: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

3. Syncing and Migrating Data

• Sync and migration scripts – take more seriously than production code

• Design sync to be continuous with both systems running in parallel during migration

• Prioritize the sync

Page 21: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

4. Don’t use C* as a Queue

• Cassandra anti-patterns: Queues and queue-like datasets[2] – Aleksey Yeschenko

• Tombstones + read performance• Our solution: – Kafka (multiple publisher, multiple consumer

durable queue)

[2]http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets

Page 22: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

5. Estimate Capacity

• Don’t forget the Java heap (8GB Max)• Plan capacity – today and future• Stress Tool – profile node and multiply• MySQL hardware != Cassandra hardware• New bottlenecks thanks to C* being so

awesome?• I/O still an important concern with C*

Page 23: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

6. Automate, Automate, Automate

• Love your inner Ops self. Distributed systems move complexity to operations.

• Puppet or something similar (really)• Learn CCM earlier rather than later– www.github.com/pcmanus/ccm

Page 24: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

7. Some Maintenance Required

• Repairs & Cleanup ops– automate and run frequently

• Rolling restart meet rolling repair

• Learn jconsole• Solution:– Jolokia (JMX via HTTP)

Page 25: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

Where is Barracuda Today?

• 2 years in production with Cassandra• Definitely the right choice for our persistence

tier• 2 product lines on C* based system and

another major product in beta• Achieved “real-time” response

Page 26: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

2.0 and Beyond

• Thrift -> CQL• CQL helps the MySQL to C* migration – Easier to comprehend / grasp

• Everyone understands SELECT * FROM cf WHERE key = ‘foo’;

• CAS and other 2.0 features make C* an even better replacement option for MySQL

Page 27: Cassandra Community Webinar: MySQL to Cassandra - What I Wish I'd Known

C* Community

• Supercalifragilisticexpialidocious community!• Riak, HBase, Oracle are other options. How is

their dev community?• Great client support. Great people. Great

motivated developers.• IRC: #cassandra on freenode• Mailing List: [email protected]