- Mailing Lists
- in
- Trillions of Indexes: How Uber’s LedgerStore Supports Such Massive Scale
Archives
- By thread 3808
-
By date
- June 2021 10
- July 2021 6
- August 2021 20
- September 2021 21
- October 2021 48
- November 2021 40
- December 2021 23
- January 2022 46
- February 2022 80
- March 2022 109
- April 2022 100
- May 2022 97
- June 2022 105
- July 2022 82
- August 2022 95
- September 2022 103
- October 2022 117
- November 2022 115
- December 2022 102
- January 2023 88
- February 2023 90
- March 2023 116
- April 2023 97
- May 2023 159
- June 2023 145
- July 2023 120
- August 2023 90
- September 2023 102
- October 2023 106
- November 2023 100
- December 2023 74
- January 2024 75
- February 2024 75
- March 2024 78
- April 2024 74
- May 2024 108
- June 2024 98
- July 2024 116
- August 2024 134
- September 2024 130
- October 2024 141
- November 2024 171
- December 2024 64
The Business Show UK 2024
You're invited! Join us for a virtual event on the physical realities of the energy transition
Trillions of Indexes: How Uber’s LedgerStore Supports Such Massive Scale
Trillions of Indexes: How Uber’s LedgerStore Supports Such Massive Scale
Try Fully Managed Apache Airflow and get certified for FREE (Sponsored)Run Airflow without the hassle and management complexity. Take Astro (the fully managed Airflow solution) for a test drive today and unlock a suite of features designed to simplify, optimize, and scale your data pipelines. For a limited time, new sign ups will receive a complimentary Airflow Fundamentals Certification exam (normally $150). Disclaimer: The details in this post have been derived from the Uber Engineering Blog. All credit for the technical details goes to the Uber engineering team. The links to the original articles are present in the references section at the end of the post. We’ve attempted to analyze the details and provide our input about them. If you find any inaccuracies or omissions, please leave a comment, and we will do our best to fix them. Ledgers are the source of truth of any financial event. By their very nature, ledgers are immutable. Also, we usually want to access data stored in these ledgers in various combinations. With billions of trips and deliveries, Uber performs tens of billions of financial transactions. Merchants, riders, and customers are involved in these financial transactions. Money flows from the ones spending to the ones earning. To manage this mountain of financial transaction data, the LedgerStore is an extremely critical storage solution for Uber. The myriad access patterns for the data stored in LedgerStore also create the need for a huge number of indexes. In this post, we’ll look at how Uber implemented the indexing architecture for LedgerStore to handle trillions of indexes and how they migrated a trillion entries of Uber’s Ledger Data from DynamoDB to LedgerStore. What is LedgerStore?LedgerStore is Uber’s custom-built storage solution for managing financial transactions. Think of it as a giant, super-secure digital ledger book that keeps track of every financial event at Uber, from ride payments to food delivery charges. What makes LedgerStore special is its ability to handle an enormous amount of data. We’re talking about trillions of entries. Two main features supported by LedgerStore are:
Ultimately, LedgerStore helps Uber manage its financial data more effectively, reducing costs compared to previous solutions. Types of IndexesLedgerStore supports three main types of indexes:
Let’s look at each of them in more detail. Strongly Consistent IndexesThese indexes provide immediate read-your-write guarantees, crucial for scenarios like credit card authorization flows. For example, when a rider starts an Uber trip, a credit card hold is placed, which must be immediately visible to prevent duplicate charges. See the diagram below that shows the credit-card payment flow for an Uber trip supported by strongly consistent indexes. If the index is not strongly consistent, the hold may take a while to be visible upon reading. This can result in duplicate charges on the user’s credit card. Strongly consistent indexes at Uber are built using the two-phase commit approach. Here’s how this approach works in the write path and read path. 1 - The Write PathThe write path consists of the following steps:
The diagram below shows this entire process. There is one special case to consider here: if the index intent write succeeds, but the record write fails, the index intent has to be rolled back to prevent the accumulation of unused intents. This part is handled during the read path. 2 - The Read PathThe below steps happen during the read path:
The diagram below shows the process steps in more detail. Reserve Your Seat Now! | Upcoming Cohort on Aug 26th, 2024 (Sponsored)Build confidence without getting lost in technical jargon. This cohort is designed to help you build a foundational understanding of software applications. You won’t just memorize a bunch of terms - you’ll actually understand how software products are designed and deployed to handle millions of users. And our community will be here to give you the support, guidance, and accountability you’ll need to finally stick with it. After only 4 weeks, you’ll look back and think.. “WOW! I can’t believe I did that.” Now imagine if you could: ✅ Master technical concepts without getting lost in an internet maze. ✅ Stop asking engineers to dumb down concepts when talking to you. ✅ Predict risks, anticipate issues, and avoid endless back-and-forth. ✅ Improve your communication with engineers, users, and technical stakeholders. Grab your spot now with an exclusive 25% off discount for ByteByteGo Readers. See you there! Eventually Consistent IndexesThese indexes are designed for scenarios where real-time consistency is not critical, and a slight delay in index updates is acceptable. They offer better performance and availability at the cost of immediate consistency. From a technical implementation point of view, the eventually consistent indexes are generated using the Materialized Views feature of Uber’s Docstore. Materialized views are pre-computed result sets stored as a table, based on a query against the base table(s). The materialized view is updated asynchronously when the base table changes. When a write occurs to the main data store, it doesn’t immediately update the index. Instead, a separate process periodically scans for changes and updates the materialized view. The consistency window is configurable and determines how frequently the background process runs to update the indexes. In Uber’s case, the Payment History Display screen uses the eventually consistent indexes. Time-range IndexesTime-range indexes are a crucial component of LedgerStore, designed to query data within specific time ranges efficiently. These indexes are important for operations like offloading older ledger data to cold storage or sealing data for compliance purposes. The main characteristic of these indexes is their ability to handle deterministic time-range batch queries that are significantly larger in scope compared to other index types. Earlier, the time-range indexes were implemented using a dual-table design approach in DynamoDB. However, it was operationally complex. The migration of LedgerStore to Uber’s Docstore paved the path for a simpler implementation of the time-range index. Here’s a detailed look at the Docstore implementation for the time-range indexes:
For clarity, consider a query to fetch all ledger entries between “2024-08-09 10:00:00” and “2024-08-09 10:30:00”. The query would be broken down into three 10-minute scans:
Each of these scans would be executed across all shards in parallel. The results would then be merged and sorted to provide the final result set. The diagram below shows the overall process: Index Lifecycle ManagementIndex lifecycle management is another component of LedgerStore’s architecture that handles the design, modification, and decommissioning of indexes. Let’s look at the main parts of the index lifecycle management system. Index Lifecycle State MachineThis component orchestrates the entire lifecycle of an index:
The state machine ensures that each step is completed correctly before moving to the next, maintaining data integrity throughout the process. The diagram below shows all the steps: Historical Index Data BackfillWhen new indexes are defined or existing ones are modified, it’s essential to backfill historical data to ensure completeness. The historical index data backfill component performs the following tasks:
Index ValidationAfter indexes are backfilled, they need to be verified for completeness. This is done through an offline job that:
From a technical point of view, the component uses a time-window approach i.e. computing checksums for every 1-hour block of data. Even if a single entry is missed, the aggregate checksum for that time window will lead to a mismatch. For example, If checksums are computed for 1-hour blocks, and an entry from 2:30 PM is missing, the checksum for the 2:00 PM - 3:00 PM block will not match. Migration of Uber’s Payment Data to LedgerStoreNow that we have understood about LedgerStore’s indexing architecture and capabilities, let’s look at the massive migration of Uber’s payment data to LedgerStore. Uber’s payment platform, Gulfstream, was initially launched in 2017 using Amazon DynamoDB for storage. However, as Uber’s operations grew, this setup became increasingly expensive and complex. By 2021, Gulfstream was using a combination of three storage systems:
The primary reasons for migrating to LedgerStore were as follows:
The migration was a massive undertaking. Some statistics are as follows:
For reference, storing this data on typical 1 TB hard drives requires a total of 1200 hard drives just for the compressed data. ChecksOne of the key goals of the migration was to ensure that the backfill was correct and acceptable. Also, the current traffic requirements needed to be fulfilled. Key validation methods adopted were as follows: 1 - Shadow ValidationThis ensured that the new LedgerStore system could handle current traffic patterns without disruption. Here’s how it worked:
2 - Offline ValidationWhile shadow validation was effective for current traffic patterns, it couldn’t provide strong guarantees about rarely-accessed historical data. This is where offline validation came into play. Here’s how it worked:
Backfill IssuesThe process of migrating Uber’s massive ledger data from DynamoDB to LedgerStore involved several backfill challenges that had to be solved:
ConclusionThe impact of Uber’s ledger data migration to LedgerStore has been amazing, with over 2 trillion unique indexes successfully transferred without a single data inconsistency detected in over six months of production use. This migration, involving 1.2 PB of compressed data and over 1 trillion entries, showcases Uber’s ability to handle massive-scale data operations without disrupting critical financial processes. It also provides great learning points for the readers. The cost savings from this migration have been substantial, with estimated yearly savings exceeding $6 million due to reduced spend on DynamoDB. Performance improvements have been notable, with LedgerStore offering shorter indexing lag and better network latency due to its on-premise deployment within Uber’s data centers. References:
© 2024 ByteByteGo |
by "ByteByteGo" <bytebytego@substack.com> - 11:35 - 20 Aug 2024