solving everyday data problems with foundationdb
play

Solving Everyday Data Problems with FoundationDB Ryan Worl - PowerPoint PPT Presentation

Solving Everyday Data Problems with FoundationDB Ryan Worl (ryantworl@gmail.com) Consultant About Me Independent software engineer Todays real example is from ClickFunnels > 70,000 customers, > 1.8B of payments processed


  1. Solving Everyday Data Problems with FoundationDB Ryan Worl (ryantworl@gmail.com) Consultant

  2. About Me ● Independent software engineer ● Today’s real example is from ClickFunnels ● > 70,000 customers, > 1.8B of payments processed ● Billions of rows of OLTP data (Amazon Aurora MySQL) ● Ryan Worl ● @ryanworl on Twitter ● ryantworl@gmail.com

  3. Agenda ● How FoundationDB Works ● “Everyday” data problems ● Why FoundationDB can be the solution ● ClickFunnels’ recent data problem ● FoundationDB for YOUR data problems

  4. Coordinators elect & heartbeat Cluster Controller (Paxos) Coordinators store core cluster state, used like ZooKeeper All processes register themselves with the Cluster Controller Cluster Controller Coordinators 1

  5. Cluster Controller (CC) assigns Master Role Master 2

  6. CC assigns TLog, Proxy, Resolver, and Storage Roles Proxy 3

  7. CC assigns TLog, Proxy, Resolver, and Storage Roles Resolver 3

  8. CC assigns TLog, Proxy, Resolver, and Storage Roles TLog 3

  9. CC assigns TLog, Proxy, Resolver, and Storage Roles Storage 3

  10. On Start: Your App Connects and Asks CC For Topology YOUR APP 4

  11. Client Library Asks a Proxy for Key Range to Storage Mapping YOUR APP 4

  12. Data Distribution Runs On Master, Key Map Stored in Database YOUR APP FF 4

  13. Start a Transaction: Ask Master for Latest Version YOUR APP 5

  14. Start a Transaction: Ask Master for Latest Version (Batched) YOUR APP 100 5

  15. Perform Reads at Read Version Directly to Storage YOUR APP 00 55 AF FF 6

  16. Consequences ● All replicas participate in reads ● Client load balances among different replicas ● Failures of all but one replica for each range keep the system alive @ryanworl

  17. Buffer Writes Locally Until Commit YOUR APP 00 00 55 55 AF AF FF FF 7

  18. Commit Part 1: Send R/W Conflict Ranges + Mutations to Proxy YOUR APP 00 00 55 55 AF AF FF FF 8

  19. Part 2: Proxy Batches Txns to Master To Get Commit Version YOUR APP A H T Z 00 00 55 55 AF AF FF FF 8

  20. Consequences ● Master is not a throughput bottleneck ● Intelligent batching makes Master workload small ● Conflict ranges and mutations are not sent to Master at all @ryanworl

  21. Part 3: Send Conflict Ranges to Resolvers for Conflict Detection YOUR APP A H T Z 00 00 55 55 AF AF FF FF 8

  22. Part 4: If Isolation Passes, Send Mutations to Relevant TLogs YOUR APP A H T Z 00 00 55 55 AF AF FF FF 8

  23. Part 5: (Async) Storages Pull Mutations from Their Buddy TLogs YOUR APP A H T Z 00 00 55 55 AF AF FF FF 8

  24. Failure Detection: Cluster Controller Heartbeats YOUR APP A H T Z 00 00 55 55 AF AF FF FF 9

  25. Initiate Recovery on Any Transaction Role Failure YOUR APP A H T Z 00 00 55 55 AF AF FF FF ฀฀ 10

  26. Cluster Controller Failure: Coordinators Elect New One YOUR APP A H T Z 00 00 55 55 AF AF FF FF ฀฀ 11

  27. Storage Server Failure: No Recovery, Repair in Background YOUR APP ฀฀ A H T Z 00 00 55 55 AF AF FF FF 12

  28. Status Quo ● Most apps start uncomplicated ● One database, one queue ● … five years later, a dozen data systems @ryanworl

  29. “Everyday” Data Problems? https://twitter.com/coda @ryanworl

  30. “Microservices” ● Can make this worse Service C Service A Service B @ryanworl

  31. Why is this a problem? ● Operational costs ○ Administrative costs ○ Duplicated data ● Development costs ○ Atomicity mostly ignored in the real world ○ Corrupted data extremely common @ryanworl

  32. Why is this a problem? ● Security costs ○ More systems = More risk ● Error handling never exercised ○ “De-coupled”, “redundant”, “fault tolerant” services mostly a myth @ryanworl

  33. Why is this a problem? ● “Managed cloud services” ○ They will never pick up the pieces ○ They will reboot the machine for you… ○ A weak system run by someone else is still weak ■ e.g. data loss from async replication @ryanworl

  34. Why is FoundationDB a solution? ● Build anything you want or need ● Multiple systems in one cluster ● Eventually consistent models easier to build too ○ OLTP Change Log OLAP @ryanworl

  35. ClickFunnels’ Recent Data Problem

  36. The Everyday Data Problem ● “Smart Lists” based on user-defined rules ● Running against billions of rows in an OLTP database ● Both user-facing and automated (100s of QPS)

  37. The Everyday Data Problem SELECT contacts.id from contacts LEFT JOIN emails on emails.contact_id = contacts.id LEFT JOIN templates on templates.id = emails.template_id WHERE ...

  38. Breaking it down ● Data volume = 100s of GB ● Complex joins and row-oriented storage ● Indexes can’t satisfy every query efficiently ● Aurora = single threaded queries ● Really just set operations on integers at the core... @ryanworl

  39. Bitmap indexes!

  40. Bitmap Indexes 101 ● Roaring Bitmap Library (roaringbitmap.org) ● Space usage proportional to number of set bits ● Billions of operations per second (SIMD) ● Easily parallelizable (multi-core and distributed) @ryanworl

  41. Bitmap Indexes 101 ● Multi-minute evaluation times of rules in Aurora ● Under 100ms with bitmaps @ryanworl

  42. New Possibilities ● Evaluating rules on every customer website page view ● “How many people will this rule match?” in real time ● Stats and analytics can adapt to this format ● E.g. unique email opens per hour with rules applied for fancy charts ● Pages load instantly even for the largest customers @ryanworl

  43. How to get there - Step One ● Replicate Aurora binlog into FoundationDB ● Write volume not high enough to worry about sharding ● Example of a log structure [“binlog”, VersionStamp] => MySQL Binlog as JSON @ryanworl

  44. How to get there - Step Two ● Chunk bitmaps into small segments (2^18 is fine) ● Evaluate rules, set bits where rules match ● One writer at a time for low contention ● Example of storing a large object among many keys [“bitmaps”, rule_id, chunk_id] => Bitmap Chunk

  45. How to get there - Step Three ● Do a range read for every chunk for each rule ● Parallelize by evaluating different ranges ● Classic fork-join pattern [“bitmaps”, rule_1, chunk_1] => Chunk CORE 1 [“bitmaps”, rule_2, chunk_1] => Chunk [“bitmaps”, rule_1, chunk_N] => Chunk CORE 2 [“bitmaps”, rule_2, chunk_N] => Chunk

  46. Experimental Results ● Real-world queries take 100ms ● One large box today ● Distributed later with little extra work ● HA from auto-scaling group and load balancer ● < 3000 lines of JavaScript + RoaringBitmap @ryanworl

  47. YOUR Everyday Data Problems ● FoundationDB’s performance ○ Concurrency Potential ○ Coordination Avoidance ● Break down the transaction critical path @ryanworl

  48. https://en.wikipedia.org/wiki/Amdahl%27s_law

  49. ~ 275 allocations / second 160ms latency and growing https://www.activesphere.com/blog/2018/08/05/high-contention-allocator

  50. > 3500 allocations / second ~ 13ms latency @ high concurrency https://www.activesphere.com/blog/2018/08/05/high-contention-allocator

  51. YOUR Everyday Data Problems ● Tables, logs, queues, secondary indexes ● Simple to implement with little code ● Freedom to build your exact solution ● … without the explosion of data systems ● One cluster to manage @ryanworl

  52. Questions ● Email or tweet me if you have questions or want to talk about specific use cases for FoundationDB @ryanworl ryantworl@gmail.com

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend