Cockroachdb: the Resilient Geo-Distributed SQL Database

Cockroachdb: the Resilient Geo-Distributed SQL Database

Industry 3: Cloud and Distributed Databases SIGMOD ’20, June 14–19, 2020, Portland, OR, USA CockroachDB: The Resilient Geo-Distributed SQL Database Rebecca Taft, Irfan Sharif, Andrei Matei, Nathan VanBenschoten, Jordan Lewis, Tobias Grieger, Kai Niemi, Andy Woods, Anne Birzin, Raphael Poss, Paul Bardea, Amruta Ranade, Ben Darnell, Bram Gruneir, Justin Jaffray, Lucy Zhang, and Peter Mattis [email protected] Cockroach Labs, Inc. ABSTRACT We live in an increasingly interconnected world, with many organizations operating across countries or even con- tinents. To serve their global user base, organizations are replacing their legacy DBMSs with cloud-based systems ca- pable of scaling OLTP workloads to millions of users. CockroachDB is a scalable SQL DBMS that was built from the ground up to support these global OLTP workloads while maintaining high availability and strong consistency. Just like its namesake, CockroachDB is resilient to disasters through replication and automatic recovery mechanisms. This paper presents the design of CockroachDB and its novel transaction model that supports consistent geo-distrib- Figure 1: A global CockroachDB cluster uted transactions on commodity hardware. We describe how CockroachDB replicates and distributes data to achieve fault ACM, New York, NY, USA, 17 pages. https://doi.org/10.1145/3318464. tolerance and high performance, as well as how its distributed 3386134 SQL layer automatically scales with the size of the database cluster while providing the standard SQL interface that users 1 INTRODUCTION expect. Finally, we present a comprehensive performance Modern transaction processing workloads are increasingly evaluation and share a couple of case studies of CockroachDB geo-distributed. This trend is fueled by the desire of global users. We conclude by describing lessons learned while build- companies to not only build scalable applications, but also ing CockroachDB over the last five years. control with fine-granularity where data resides for perfor- mance and regulatory reasons. ACM Reference Format: Consider, for example, a large company with a core user Rebecca Taft, Irfan Sharif, Andrei Matei, Nathan VanBenschoten, base in Europe and Australia and a fast growing user base Jordan Lewis, Tobias Grieger, Kai Niemi, Andy Woods, Anne Birzin, Raphael Poss, Paul Bardea, Amruta Ranade, Ben Darnell, Bram in the US. To power its global platform while reducing oper- Gruneir, Justin Jaffray, Lucy Zhang, and Peter Mattis. 2020. Cock- ational costs, the company has made the strategic decision roachDB: The Resilient Geo-Distributed SQL Database. In Proceed- to migrate to a cloud-based database management system ings of the 2020 ACM SIGMOD International Conference on Manage- (DBMS). It has the following requirements: to comply with ment of Data (SIGMOD’20), June 14ś19, 2020, Portland, OR, USA. the EU’s General Data Protection Regulation (GDPR), per- sonal data for its European users must be domiciled within the EU. To avoid high latencies due to cross-continental com- munication, data should reside close to the users accessing it most frequently, and follow them (within regulatory limits) This work is licensed under a Creative Commons Attribution-ShareAlike if they travel. Users expect an łalways onž experience, so the International 4.0 License. DBMS must be fault tolerant, even surviving a full regional SIGMOD’20, June 14ś19, 2020, Portland, OR, USA © 2020 Copyright held by the owner/author(s). failure. Finally, to avoid data anomalies and to simplify ap- ACM ISBN 978-1-4503-6735-6/20/06. plication development, the DBMS must support SQL with https://doi.org/10.1145/3318464.3386134 serializable transactions. 1493 Industry 3: Cloud and Distributed Databases SIGMOD ’20, June 14–19, 2020, Portland, OR, USA SIGMOD’20, June 14ś19, 2020, Portland, OR, USA R. Taft, I. Sharif, A. Matei, N. VanBenschoten, J. Lewis, T. Grieger etal. CockroachDB (abbrev. CRDB) is a commercial DBMS de- the database provides fault tolerance and high availability signed to support all of the aforementioned requirements. As through replication and strategic data placement. Section 3 a case in point, the company described above is a real orga- provides a deep-dive into CRDB’s transaction model. Sec- nization in the process of migrating their global platform to tion 4 explains how we use timestamp ordering to achieve CRDB, and Fig. 1 shows the strategic vision for their CRDB strong consistency, even with loosely synchronized clocks deployment. In this paper, we present the design and imple- on commodity hardware. Section 5 describes the SQL data mentation of CRDB and explain in detail the rationale for model, planning, execution, and schema changes. Section 6 the decisions we made, as well as some lessons learned along evaluates the performance of CRDB and contains two case the way. We explain how CRDB supports the requirements studies of CRDB usage. Section 7 summarizes our lessons of global companies such as the one above by focusing on learned while building CRDB. Section 8 describes related the following features: work, and Section 9 presents conclusions and future work. (1) Fault tolerance and high availability To provide fault 2 SYSTEM OVERVIEW tolerance, CRDB maintains at least three replicas of every This section begins with an overview of CRDB’s archi- partition in the database across diverse geographic zones. tecture in Section 2.1. Sections 2.2 and 2.3 describe how the It maintains high availability through automatic recovery system replicates and distributes data to provide fault toler- mechanisms whenever a node fails. ance, high availability, and geo-distributed partitioning. (2) Geo-distributed partitioning and replica placement CRDB is horizontally scalable, automatically increasing 2.1 Architecture of CockroachDB capacity and migrating data as nodes are added. By de- CRDB uses a standard shared-nothing [62] architecture, fault it uses a set of heuristics for data placement (see in which all nodes are used for both data storage and com- Section 2.2.3), but it also allows users to control, at a fine putation. A CRDB cluster consists of an arbitrary number granularity, how data is partitioned across nodes and of nodes, which may be colocated in the same datacenter or where replicas should be located. We will describe how spread across the globe. Clients can connect to any node in users can use this feature for performance optimization the cluster. or as part of a data domiciling strategy. Within a single node, CRDB has a layered architecture. (3) High-performance transactions CRDB’s novel trans- We now introduce each of the layers, including concepts and action protocol supports performant geo-distributed trans- terminology used throughout the paper. actions that can span multiple partitions. It provides se- 2.1.1 SQL. At the highest level is the SQL layer, which is rializable isolation using no specialized hardware; a stan- the interface for all user interactions with the database. It dard clock synchronization mechanism such as NTP is includes the parser, optimizer, and the SQL execution engine, sufficient. As a result, CRDB can be run on off-the-shelf which convert high-level SQL statements to low-level read servers, including those of public and private clouds. and write requests to the underlying key-value (KV) store. CRDB is a production-grade system that was designed to In general, the SQL layer is not aware of how data is łmake data easyž, so in addition to the above, CRDB supports partitioned or distributed, because the layers below present the SQL standard with a state-of-the-art query optimizer and the abstraction of a single, monolithic KV store. Section 5 will distributed SQL execution engine. It also includes all the fea- describe how certain queries break this abstraction, however, tures necessary for our users to run CRDB in production as a for more efficient distributed SQL computation. system of record, including online schema changes, backup 2.1.2 Transactional KV. Requests from the SQL layer are and restore, fast imports, JSON support, and integration with passed to the Transactional KV layer that ensures atomic- external analytics systems. ity of changes spanning multiple KV pairs. It is also largely All of the source code of CRDB is available on GitHub [12]. responsible for CRDB’s isolation guarantees. These atom- The core features of the database are under a Business Source icity and isolation guarantees will be described in detail in License (BSL), which converts to a fully open-source Apache Sections 3 and 4. 2.0 license after three years [13]. Additionally, CRDB is łcloud- 2.1.3 Distribution. This layer presents the abstraction of neutralž, meaning a single CRDB cluster can span an arbi- a monolithic logical key space ordered by key. All data is trary number of different public and private clouds. These addressable within this key space, whether it be system data two features enable users to mitigate the risks of vendor lock- (used for internal data structures and metadata) or user data in, such as reliance on proprietary extensions of SQL [6, 23] (SQL tables and indexes). or exposure to cloud provider outages [70]. CRDB uses range-partitioning on the keys to divide the The remainder of the paper is organized as follows: In Sec- data into contiguous ordered chunks of size ~64 MiB, that tion 2, we present an overview of CRDB, summarizing how are stored across the cluster. We call these chunks łRangesž. 1494 Industry 3: Cloud and Distributed Databases SIGMOD ’20, June 14–19, 2020, Portland, OR, USA CockroachDB: The Resilient Geo-Distributed SQL Database SIGMOD’20, June 14ś19, 2020, Portland, OR, USA Ordering between Ranges is maintained in a two-level index- log entry. To prevent two replicas from acquiring leases ing structure inside a set of system Ranges, which are cached overlapping in time, lease acquisition requests include a copy aggressively for fast key lookups. The Distribution layer is re- of the lease believed to be valid at the time of request.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    17 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us