Scuba: Diving Into Data at Facebook
Total Page:16
File Type:pdf, Size:1020Kb
Scuba: Diving into Data at Facebook ∗ Lior Abraham John Allen Oleksandr Barykin Vinayak Borkar Bhuwan Chopra Ciprian Gerea Daniel Merl Josh Metzler David Reiss Subbu Subramanian Janet L. Wiener Okay Zed Facebook, Inc. Menlo Park, CA ABSTRACT Originally, we relied on pre-aggregated graphs and a carefully Facebook takes performance monitoring seriously. Performance managed, hand-coded, set of scripts over a MySQL database of per- issues can impact over one billion users so we track thousands of formance data. By 2011, that solution became too rigid and slow. servers, hundreds of PB of daily network traffic, hundreds of daily It could not keep up with the growing data ingestion and query code changes, and many other metrics. We require latencies of rates. Other query systems within Facebook, such as Hive [20] and under a minute from events occuring (a client request on a phone, a Peregrine [13], query data that is written to HDFS with a long (typ- bug report filed, a code change checked in) to graphs showing those ically one day) latency before data is made available to queries and events on developers’ monitors. queries themselves take minutes to run. Scuba is the data management system Facebook uses for most Therefore, we built Scuba, a fast, scalable, in-memory database. real-time analysis. Scuba is a fast, scalable, distributed, in-memory Scuba is a significant evolution in the way we collect and analyze database built at Facebook. It currently ingests millions of rows data from the variety of systems that keep the site running every (events) per second and expires data at the same rate. Scuba stores day. We now use Scuba for most real-time, ad-hoc analysis of arbi- data completely in memory on hundreds of servers each with 144 trary data. We compare Scuba to other data management systems GB RAM. To process each query, Scuba aggregates data from all later in the paper, but we know of no other system that both ingests servers. Scuba processes almost a million queries per day. Scuba is data as fast and runs complex queries as fast as Scuba. used extensively for interactive, ad hoc, analysis queries that run in Today, Scuba runs on hundreds of servers each with 144 GB under a second over live data. In addition, Scuba is the workhorse RAM in a shared-nothing cluster. It stores around 70 TB of com- behind Facebook’s code regression analysis, bug report monitoring, pressed data for over 1000 tables in memory, distributed by par- ads revenue monitoring, and performance debugging. titioning each table randomly across all of the servers. Scuba in- gests millions of rows per second. Since Scuba is memory-bound, it expires data at the same rate. To constrain the amount of data, 1. INTRODUCTION Scuba allows rows to specify an optional sample rate, which in- At Facebook, whether we are diagnosing a performance regres- dicates that Scuba contains only a fraction (often 1 in 100 to 1 in sion or measuring the impact of an infrastructure change, we want 1,000,000) of the original events. This sampling is necessary for data and we want it fast. The Facebook infrastructure team relies events like Facebook client requests, which occur millions of times on real-time instrumentation to ensure the site is always running per second. Sampling may be either uniform or based on some smoothly. Our needs include very short latencies (typically under a key, such as user id. Scuba compensates for the sample rate when minute) between events occuring on the web servers running Face- computing aggregates. book to those events appearing in the graphs produced by queries. In addition to a SQL query interface (for a subset of SQL in- Flexibility and speed in querying data is critical for diagnosing cluding grouping and aggregations but not joins), Scuba provides any issues quickly. Identifying the root cause for a issue is often a GUI that produces time series graphs, pie charts, distributions of difficult due to the complex dependencies between subsystems at column values, and a dozen other visualizations of data besides ta- Facebook. Yet if any issues are not fixed within minutes to a few bles with text. Figure 1 shows a time series graph with a week over hours, Facebook’s one billion users become unhappy and that is week comparison of page traffic in the Scuba GUI. In the backend, bad for Facebook. an aggregation tree distributes each query to every server and then ∗ gathers the results to send back to the client. Lior Abraham, John Allen, and Okay Zed were key early con- Although Scuba was built to support performance analysis, it tributors to Scuba who have left Facebook. Vinayak Borkar is a soon became the system of choice to execute exploratory queries Facebook graduate fellow from U.C. Irvine. over other time-sensitive data. Many teams at Facebook use Scuba: Permission to make digital or hard copies of all or part of this work for • Mobile development teams use Scuba to track which frac- personal or classroom use is granted without fee provided that copies are tions of users are running different mobile devices, operating not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. To copy otherwise, to systems, and versions of the Facebook app. republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Articles from this volume were invited to present • Ads uses Scuba to monitor changes in ad impressions, clicks, their results at The 39th International Conference on Very Large Data Bases, and revenue. When a drop occurs, they can narrow it down August 26th - 30th 2013, Riva del Garda, Trento, Italy. Proceedings of the VLDB Endowment, Vol. 6, No. 11 quickly to a particular country, ad type, or server cluster and Copyright 2013 VLDB Endowment 2150-8097/13/09... $ 10.00. determine the root issue. Figure 1: Scuba’s web user interface. The query shown on the left side generates a time series graph with a week over week comparison of three columns related to Facebook page dispatches. The dotted lines represent the same days one week earlier. It is very easy to see daily and weekly cyclical behavior with these graphs. • Site reliability watches server errors by using Scuba. When 2. SCUBA USE CASES a spike occurs, they can pinpoint whether it is due to a bug in Scuba currently stores over 1000 tables. In this section, we de- a particular endpoint, a service in a particular datacenter or scribe a few representative use cases of Scuba. server cluster, or a physical issue with part of a datacenter. 2.1 Performance Monitoring • Bug report monitoring runs thousands of queries every hour The original and most common use of Scuba is for real-time to look for spikes in the number of bugs reported by Face- performance monitoring. Julie monitors the performance of face- book users, grouped by dozens of demographic dimensions book.com. She starts by looking at a Scuba dashboard of tens of (location, age, friend count, etc). graphs showing CPU load on servers; numbers of cache requests, In general, users start by asking high-level aggregate queries to hits, and misses; network throughput; and many other metrics. identify interesting phenomena in their data and then dive deeper These graphs compare performance week over week, as in Fig- (hence the name Scuba) to find base data points of interest. In all ure 1, or before and after a big code change. Whenever she finds of the above cases, being able to break down the data along multiple a significant performance difference, she then drills down through dimensions in an ad hoc manner is crucial. different columns (often including stack traces), refining the query Scuba is also the engine that underlies Facebook’s code regres- until she can pin the difference to a particular block of code and fill sion analysis tool, bug report monitoring tool, real-time post con- out an urgent bug report. tent monitoring tool (e.g., how many Facebook posts mention the Julie’s dashboard runs canned queries over data that is no more movie “Argo”?), and many other tools. The key feature of Scuba is than seconds old. Performance bugs can often be spotted (and that queries take less than a second to execute, even when scanning fixed!) within minutes to hours of their introduction — and while hundreds of GB of data, and results are usually live over events that they are still being tested on a fraction of the site. Alerts on spikes occurred a minute ago. in these performance graphs automate much of her initial monitor- In Section 2, we describe some of the use cases supported by ing. Logging and importing data in real-time over all of Facebook’s Scuba at Facebook, including performance monitoring, trend spot- servers would be too expensive; Julie’s table contains samples of ting, and pattern mining. A detailed description of Scuba’s archi- about 1 in 10,000 events (but it varies for different tables and types tecture, storage, and query capabilities is in Section 3. We present a of events). Scuba records the sampling rate and compensates for it. simple analytical model of Scuba’s query execution in Section 4. In Section 5, we evaluate Scuba experimentally. We study its speedup 2.2 Trend Analysis and scaleup properties with real data and queries. In Section 6, we Another time sensitive use of Scuba is trend spotting. Eric looks compare Scuba to related work. We conclude in Section 7 with a for trends in data content.