Weaver: a High-Performance, Transactional Graph Database Based on Refinable Timestamps
Total Page:16
File Type:pdf, Size:1020Kb
Weaver: A High-Performance, Transactional Graph Database Based on Refinable Timestamps Ayush Dubey Greg D. Hill Robert Escriva Cornell University Stanford University Cornell University Emin Gun¨ Sirer Cornell University ABSTRACT may erroneously conclude that n7 is reachable from n1, even Graph databases have become a common infrastructure com- though no such path ever existed. ponent. Yet existing systems either operate on offline snap- Providing strongly consistent queries is particularly chal- shots, provide weak consistency guarantees, or use expensive lenging for graph databases because of the unique charac- concurrency control techniques that limit performance. teristics of typical graph queries. Queries such as traversals In this paper, we introduce a new distributed graph data- often read a large portion of the graph, and consequently base, called Weaver, which enables efficient, transactional take a long time to execute. For instance, the average degree graph analyses as well as strictly serializable ACID transac- of separation in the Facebook social network is 3.5 [8], which tions on dynamic graphs. The key insight that allows Weaver implies that a breadth-first traversal that starts at a random to combine strict serializability with horizontal scalability vertex and traverses 4 hops will likely read all 1.59 billion and high performance is a novel request ordering mecha- users. On the other hand, typical key-value and relational nism called refinable timestamps. This technique couples queries are much smaller; the NewOrder transaction in the coarse-grained vector timestamps with a fine-grained timeline TPC-C benchmark [7], which comprises 45% of the frequency oracle to pay the overhead of strong consistency only when distribution, consists of 26 reads and writes on average [21]. needed. Experiments show that Weaver enables a Bitcoin Techniques such as optimistic concurrency control or dis- blockchain explorer that is 8× faster than Blockchain.info, tributed two-phase locking result in poor throughput when and achieves 10:9× higher throughput than the Titan graph concurrent queries try to read large subsets of the graph. database on social network workloads and 4× lower latency Due to the unique nature of typical graph-structured data than GraphLab on offline graph traversal workloads. and queries, existing databases have offered limited sup- port. State-of-the-art transactional graph databases such as Neo4j [6] and Titan [9] employ heavyweight coordination 1. INTRODUCTION techniques for transactions. Weakly consistent online graph Graph-structured data arises naturally in a wide range of databases [11, 15] forgo strong semantics for performance, fields that span science, engineering, and business. Social which limits their scope to applications with loose consistency networks, the world wide web, biological interaction networks, needs and requires complicated client logic. Offline graph knowledge graphs, cryptocurrency transactions, and many processing systems [26, 3, 41, 53] do not permit updates to classes of business analytics are naturally modeled as a set the graph while processing queries. Lightweight techniques of vertices and edges that comprise a graph. Consequently, for modifying and querying a distributed graph with strong there is a growing need for systems which can store and consistency guarantees have proved elusive thus far. process large-scale graph-structured data. Weaver1 is a new online, distributed, and transactional Correctness and consistency in the presence of changing graph database that supports efficient graph analyses. The data is a key challenge for graph databases. For example, key insight that enables Weaver to scalably execute graph imagine a graph database used to implement a network transactions in a strictly serializable order is a novel technique controller that stores the network topology shown in Fig. 1. called refinable timestamps. This technique uses a highly scal- When the network is undergoing churn, it is possible for a able and lightweight timestamping mechanism for ordering path discovery query to return a path through the network the majority of operations and relies on a fine-grained time- that did not exist at any instant in time. For instance, if line oracle for ordering the remaining, potentially-conflicting the link (n3; n5) fails, and subsequently the link (n5; n7) reads and writes. This unique two-step ordering technique goes online, a path query starting from host n1 to host n7 with proactive timestamping and a reactive timeline oracle has three advantages. First, refinable timestamps enable Weaver to distribute the graph across multiple shards and still execute transactions This work is licensed under the Creative Commons Attribution- NonCommercial-NoDerivatives 4.0 International License. To view a copy in a scalable fashion. There are some applications and work- of this license, visit http://creativecommons.org/licenses/by-nc-nd/4.0/. For loads for which sharding is unnecessary [43]. However many any use beyond those covered by this license, obtain permission by emailing applications support a large number of concurrent clients and [email protected]. Proceedings of the VLDB Endowment, Vol. 9, No. 11 1 Copyright 2016 VLDB Endowment 2150-8097/16/07. http://weaver.systems, https://github.com/dubey/weaver 852 n2 begin_weaver_tx() n4 photo= create_node() n1 own_edge= create_edge(user, photo) assign_property(own_edge,"OWNS") n3 for nbr in permitted_neighbors: access_edge= create_edge(photo, nbr) n7 assign_property(access_edge,"VISIBLE") n6 commit_weaver_tx() n5 Figure 2: A Weaver transaction which posts a photo in a social Figure 1: A graph undergoing an update which creates (n5; n7) network and makes it visible to a subset of the user's friends. and deletes (n3; n5) concurrently with a traversal starting at n1. In absence of transactions, the query can return path (n1; n3; n5; n7) \color=blue" property. This enables applications to attach which never existed. data to vertices and edges. operate on graphs of such large scale, consisting of billions of 2.2 Transactions for Graph Updates vertices and edges [61, 34, 46], that a single-machine archi- Weaver provides transactions over the directed graph ab- tecture is infeasible. For such high-value applications [11, 54] straction. These transactions comprise reads and writes on it is critical to distribute the graph data in order to balance vertices and edges, as well as their associated attributes. The the workload and to enable highly-parallel in-memory query operations are encapsulated in a block and may processing by minimizing disk accesses. weaver_tx use methods such as and to read the Second, refinable timestamps reduce the amount of co- get_vertex get_edge graph, and to ordination required for execution of graph analysis queries. create/delete_vertex create/delete_edge modify the graph structure, and Concurrent transactions that do not overlap in their data assign/delete_properties to assign or remove attribute data on vertices and edges. sets can execute independently without blocking each other. Fig. 2 shows the code for an update to a social network that Refinable timestamps order only those transactions that over- posts content and manages the access control for that content lap in their read-write sets, using a combination of vector in the same atomic transaction. clock ordering and the timeline oracle. Third, refinable timestamps enable Weaver to store a multi- 2.3 Node Programs for Graph Analyses version graph by marking vertices and edges with the time- stamps of the write operations. A multi-version graph lets Weaver also provides specialized, efficient support for a long-running graph analysis queries operate on a consistent class of read-only graph queries called node programs. Sim- version of the graph without blocking concurrent writes. It ilar to stored procedures in databases [24], node programs also allows historical queries which run on past, consistent traverse the graph in an application-specific fashion, reading versions of the graph. the vertices, edges, and associated attributes via the node Overall, this paper makes the following contributions: argument. For example, Fig. 3 describes a node program • It describes the design of an online, distributed, fault- that executes BFS using only edges annotated with a spec- tolerant, and strongly consistent graph database that ified edge property. Such queries operate atomically and achieves high performance and enables ACID transac- in isolation on a logically consistent snapshot of the graph. tions and consistent graph queries. Weaver queries wishing to modify the graph must collate the changes they wish to make in a node program and submit • It details a novel, lightweight ordering mechanism called them as a transaction. refinable timestamps that enables the system to trade Weaver's node programs employ a mechanism similar off proactive synchronization overheads with reactive to the commonly used scatter-gather approach [41, 3, 26] discovery of ordering information. to propagate queries to other vertices. In this approach, • It shows that these techniques are practical through each vertex-level computation is passed query parameters a full implementation and an evaluation that shows (prog_params in Fig. 3) from the previous hop vertex, sim- that Weaver scales well to handle graphs with over a ilar to the gather phase. Once a node program completes billion edges and significantly outperforms state-of-the- execution on a given vertex, it returns a list of vertex handles art