GRIT: Consistent Distributed Transactions Across Polyglot Microservices with Multiple Databases

GRIT: Consistent Distributed Transactions Across Polyglot Microservices with Multiple Databases

GRIT: Consistent Distributed Transactions across Polyglot Microservices with Multiple Databases Guogen Zhang Kun Ren Jung-Sang Ahn Sami Ben-Romdhane eBay Inc. eBay Inc. eBay Inc. eBay Inc. San Jose, USA San Jose, USA San Jose, USA San Jose, USA [email protected] [email protected] [email protected] [email protected] Abstract—The popular microservice architecture for applica- plications would have to be rewritten in such a new language, tions brings new challenges for consistent distributed transac- defeating the purpose of microservice architecture. tions across multiple microservices. These microservices may The traditional technique is to use two-phase commit (2PC) be implemented in different languages, and access multiple underlying databases. Consistent distributed transactions are a protocol [10] to achieve distributed transactions. Unfortunately real requirement but are very hard to achieve with existing it does not work well in large-scale high-throughput systems, technologies in these environments. In this demo we present in particular for the applications that have a lot of transaction GRIT: a system that resolves this challenge by cleverly leveraging conflicts [2]. The reason is that locks are held during the deterministic database technologies and optimistic concurrency entire 2PC process that significantly increase the transaction control protocol(OCC). A transaction is optimistically executed with its read-set and write-set captured during the execution conflicts and latency. Other methods include persistent mes- phase. Then at the commit time, conflict checking is performed sage queue pattern for loosely coupled distributed transactions and a global commit decision is made. A logically committed [13], which requires some framework and application logic to transaction is persisted into logs first, and then asynchronously compensate failed transaction steps or even business policy to applied to the physical databases deterministically. GRIT is able remediate through business measures, costing business money to achieve consistent, high throughput and serializable distributed transactions for any applications invoking microservices. The and impacting user experiences. Systems like Spanner [4], demonstration offers a walk-through of how GRIT can easily YugaByte [8], FoundationDB [7] and CockroachDB [9] can support distributed transactions across multiple microservices achieve distributed transactions on a single database, which and databases. cannot be applied to cross multiple microservices. Keywords-microservice, distributed transactions, OCC, deter- Recently deterministic database systems Calvin [2] [3] ministic and FAUNADB [5] were proposed, they are able to scale distributed transactions without 2PC protocol. The idea is that I. INTRODUCTION all transactions are ordered using a global Paxos-based [6] log Microservice architecture [1] is widely used in large-scale before execution, then all replicas will follow this global order cloud data platforms and application development. Microser- to deterministically execute the transactions using determinis- vice architecture provides flexibility for application develop- tic concurrency control protocol. If a transaction’s read/write ment and reuse of fine-grained services. Microservices can sets are known, then the transaction is simply put into the be developed by different domain teams to support business global transaction log. Otherwise, it needs to send read-only applications. They may be implemented in various languages, reconnaissance query that performs all the necessary reads to such as Java or Golang, and access multiple underlying discover the transaction’s full read/write set before being put databases. Applications in a microservice architecture usually into the global transaction log. During the actual transaction require invocation of multiple microservices, which access execution, the transaction might be aborted and restarted if multiple databases. When an application invokes multiple mi- the “reconnoitered” read/write set is no longer valid. This is croservices, it needs distributed transactions to make consistent possible because the records read in the reconnaissance phase updates to underlying databases. However, how to support might be changed by other transactions. consistent distributed transactions in scale-out databases is This approach is able to achieve higher transaction through- a well-known challenge, and is even more challenging in a put because of simplified replication protocol and deadlock microservice architecture. avoidance. Unfortunately this approach still needs one-phase It is possible that we implement some scalable distributed commit for distributed transactions to gather commit/abort transaction support with a special language, and dictate that decisions from all involved data shards and make the final applications be written in this special language (such as transaction commit/abort decision, and the locks are held SQL/PSM [12]). But this will not be compatible with the during the one-phase commit that increases the conflict con- microservice architecture. In addition, there could be complex tention. In addition, these systems only know the commit/abort logic in microservice and application implementation. Devel- decision during the actual execution phase which significantly oping such a language is not a small effort. Furthermore, ap- increase latency for aborted transactions. Applications Applications • GTL: Global Transaction Log. It represents the trans- action request queue for a GTM. The order in a GTL GTMGTM determines the relative serializability order among global EntityEntity Service Service EntityEntity Service Service transactions. Persistence of GTLs is optional. GTLGTL • DBTM: Transaction Manager at each database realm. DBTM DBTM DBDB Service Service DBDB Service Service The conflict checking and resolution, i.e. local commit DBTL DBTL decision, is located here. A database realm is the scope of a database covered by this DBTM for conflict checking. reads LogPlayer LogPlayer reads writes It can be a database, a shard or multiple shards of the writes database (we use database to mean database realm for . simplicity). There can only be one DBTM for a database. DB DB DB DB DB DB DB DB DB DB DB DB Shard Shard . Shard Shard Shard . Shard Shard Shard Shard Shard Shard Shard Server Server Server Server Server Server • Server Server . Server Server Server . Server DBTL: Transaction Commit Log for a DBTM at each database. It logs logically committed transactions that relate to this database (including single database trans- Fig. 1. System Architecture Illustated with Two Databases actions and multi-database transactions). The transaction order in a DBTL determines the serializability order in the database system, and global transactions from GTLs are reflected here. It is analogous to a write-ahead log (WAL) GRIT leverages some deterministic ideas, such as ordering for committed transactions in a traditional database. transactions in Paxos-based logs before execution. Similar to • Log Player: It pushes commit log entries to their target reconnaissance phase in Calvin, we perform the OCC execu- database shard servers for write execution. Its role is the tion phase [11] which optimistically executes the transaction same as that of a log replication. logic in microservices and saves the temporary write results. • DB Shard Servers: Deterministic database engines. Each Our system is distinct from Calvin/FAUNADB in that we use server uses deterministic concurrency control to material- our novel deterministic conflict resolution algorithm to resolve ize logically committed transactions concurrently. It also conflicts immediately after the OCC execution phase, then need to support multi-versioning and snapshot reads for we can know the local abort/commit decision, and perform isolation. quick global commit coordination before persisting it into the There are some other components in our system: commit logs. Obviously GRIT can significantly reduce the transaction latency for aborted transactions. This also indicates • Microservice: building blocks to provide business- that only committed transactions go to the transaction logs, oriented service for applications to implement business and no further execution is needed during the transaction log logic. Each DB may have support for multiple microser- execution (physical materialization). Furthermore, the log play vices, and executions of microservices are independent phase (corresponding to Calvin’s execution) becomes pretty of each other. simple, just to apply the write operations that are already • DB Service: Provide DB server read/write interface and calculated during the OCC execution phase. That’s why we directly access DB Servers. It also caches the read/write call it physical materialization of transactions. sets of each transaction during the execution phase and In this demo, we showcase GRIT: a novel system that sup- sends them to its DBTM for conflict resolution at the ports consistent distributed transactions across microservices commit time. There is no limit on how many DB service that are implemented in various languages and use multiple instances a system can have. underlying databases. The system is efficient and scalable, We leverage the well-known optimistic concurrency con- and provides serializability for transactions across multiple trol (OCC) for execution of microservices and application databases exposed through microservices. We use a simplified logic. And at the commit time,

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    4 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