YouTube Vitess. Cloud-Native MySQL. Oracle OpenWorld Conference October 26, 2015. Anthony Yeh, Software Engineer, YouTube. http://vitess.



Similar documents
Enabling Database-as-a-Service (DBaaS) within Enterprises or Cloud Offerings

Elastic Scalability in MySQL Fabric using OpenStack

Using MySQL for Big Data Advantage Integrate for Insight Sastry Vedantam

Overview of Databases On MacOS. Karl Kuehn Automation Engineer RethinkDB

Zero Downtime Deployments with Database Migrations. Bob Feldbauer

Solving Large-Scale Database Administration with Tungsten

MySQL és Hadoop mint Big Data platform (SQL + NoSQL = MySQL Cluster?!)

Practical Cassandra. Vitalii

DISTRIBUTED SYSTEMS [COMP9243] Lecture 9a: Cloud Computing WHAT IS CLOUD COMPUTING? 2

Welcome to Virtual Developer Day MySQL!


MongoDB Developer and Administrator Certification Course Agenda

High-Availability in the Cloud Architectural Best Practices

XDB. Shared MySQL hosting at Facebook scale. Evan Elias Percona Live MySQL Conference, April 2015

Achieving Zero Downtime and Accelerating Performance for WordPress

F1: A Distributed SQL Database That Scales. Presentation by: Alex Degtiar (adegtiar@cmu.edu) /21/2013

How To Choose Between A Relational Database Service From Aws.Com

Storing and Processing Sensor Networks Data in Public Clouds

Scalable Architecture on Amazon AWS Cloud

The Cloud to the rescue!

MySQL Strategy. Morten Andersen, MySQL Enterprise Sales. Copyright 2014 Oracle and/or its affiliates. All rights reserved.

From the Monolith to Microservices: Evolving Your Architecture to Scale. Randy linkedin.com/in/randyshoup

Distributed Scheduling with Apache Mesos in the Cloud. PhillyETE - April, 2015 Diptanu Gon

Scalability of web applications. CSCI 470: Web Science Keith Vertanen

Cloud Based Application Architectures using Smart Computing

Database Scalability and Oracle 12c

High Availability Solutions for the MariaDB and MySQL Database

WINDOWS AZURE DATA MANAGEMENT AND BUSINESS ANALYTICS

MySQL Cluster New Features. Johan Andersson MySQL Cluster Consulting johan.andersson@sun.com

Enterprise-level EE: Uptime, Speed, and Scale

Web Application Deployment in the Cloud Using Amazon Web Services From Infancy to Maturity

Implementing the Future of PostgreSQL Clustering with Tungsten

Cloud Computing: Meet the Players. Performance Analysis of Cloud Providers

Oracle Net Service Name Resolution

Search Big Data with MySQL and Sphinx. Mindaugas Žukas

Why Zalando trusts in PostgreSQL

Sharding with postgres_fdw

A programming model in Cloud: MapReduce

Web Application Hosting in the AWS Cloud Best Practices

Scaling Database Performance in Azure

Scaling Pinterest. Yash Nelapati Ascii Artist. Pinterest Engineering. Saturday, August 31, 13

On- Prem MongoDB- as- a- Service Powered by the CumuLogic DBaaS Platform

TECHNOLOGY WHITE PAPER Jun 2012

Deploy. Friction-free self-service BI solutions for everyone Scalable analytics on a modern architecture

Comparing MySQL and Postgres 9.0 Replication

Docker : devops, shared registries, HPC and emerging use cases. François Moreews & Olivier Sallou

Managing MySQL Scale Through Consolidation

Docker Java Application with Solr, Mongo, & Cassandra: Design, Deployment, Service Discovery, and Management in Production

Web Application Hosting in the AWS Cloud Best Practices

Oracle Database 12c Plug In. Switch On. Get SMART.

Virtualizing Apache Hadoop. June, 2012

CloudCenter Full Lifecycle Management. An application-defined approach to deploying and managing applications in any datacenter or cloud environment

Portable Scale-Out Benchmarks for MySQL. MySQL User Conference 2008 Robert Hodges CTO Continuent, Inc.

Tushar Joshi Turtle Networks Ltd

SCALABLE DATA SERVICES

NetflixOSS A Cloud Native Architecture

Preparing for the Big Oops! Disaster Recovery Sites for MySQL. Robert Hodges, CEO, Continuent MySQL Conference 2011

Pulsar Realtime Analytics At Scale. Tony Ng April 14, 2015

Big Data Analytics Nokia

In Memory Accelerator for MongoDB

White Paper. Optimizing the Performance Of MySQL Cluster

The Future of PostgreSQL High Availability Robert Hodges - Continuent, Inc. Simon Riggs - 2ndQuadrant

Dave Stokes MySQL Community Manager

Future-Proofing MySQL for the Worldwide Data Revolution

Deploying and Managing SolrCloud in the Cloud ApacheCon, April 8, 2014 Timothy Potter. Search Discover Analyze

Where We Are. References. Cloud Computing. Levels of Service. Cloud Computing History. Introduction to Data Management CSE 344

SQL Server 2014 New Features/In- Memory Store. Juergen Thomas Microsoft Corporation

Cloud Computing. Lecture 24 Cloud Platform Comparison

Building Success on Acquia Cloud:

How to choose High Availability solutions for MySQL MySQL UC 2010 Yves Trudeau Read by Peter Zaitsev. Percona Inc MySQLPerformanceBlog.

MySQL and Virtualization Guide

<Insert Picture Here> Oracle In-Memory Database Cache Overview

Hypertable Architecture Overview

Adding Indirection Enhances Functionality

<Insert Picture Here> Oracle NoSQL Database A Distributed Key-Value Store

Open Source Technologies on Microsoft Azure

Storage and Disaster Recovery

Big Data with Component Based Software

MySQL High-Availability and Scale-Out architectures

Cloud Computing Trends

Best Practices for Using MySQL in the Cloud

Hadoop and Map-Reduce. Swati Gore

Sharding and MongoDB. Release MongoDB, Inc.

Parallel Replication for MySQL in 5 Minutes or Less

Low-cost Open Data As-a-Service in the Cloud

Apache HBase. Crazy dances on the elephant back

Linas Virbalas Continuent, Inc.

Linux A first-class citizen in Windows Azure. Bruno Terkaly bterkaly@microsoft.com Principal Software Engineer Mobile/Cloud/Startup/Enterprise

MySQL Security: Best Practices

owncloud Architecture Overview

Drupal in the Cloud. Scaling with Drupal and Amazon Web Services. Northern Virginia Drupal Meetup

Log management with Logstash and Elasticsearch. Matteo Dessalvi

Data Warehousing and Analytics Infrastructure at Facebook. Ashish Thusoo & Dhruba Borthakur athusoo,dhruba@facebook.com

Veeam Summer School. Thomas Zaatman Veeam Software

Transcription:

YouTube Vitess Cloud-Native MySQL Oracle OpenWorld Conference October 26, 2015 Anthony Yeh, Software Engineer, YouTube http://vitess.io/

Spoiler Alert

Spoilers 1. History of Vitess 2. What is Cloud-Native Computing? 3. What is Cloud-Native MySQL? 4. Vitess Architecture 5. Transparent Live Resharding 6. Example Resharding Workflow 7. Cloud Scaling Benchmarks 8. Vitess Roadmap 9. It was all a dream

Histoir de Vitess

Vitess 1.0 golang.org YouTube is a MySQL app Vitess started in YouTube data centers Connection-pooling proxy Early adopter of Go (golang.org) First commit (in original repo) in 2010 2 years before Go 1.0 Cheap connections, goroutines In production at YouTube since 2011 5

Vitess 1.5 YouTube moved into Borg [1] Google MySQL Adapted Vitess to Borg environment Dynamically scheduled container cluster Over time, Vitess evolved within Borg Database protection Query rewriting/blacklisting Row-based cache Shard routing Cluster management Monitoring [1] http://research.google.com/pubs/pub43438.html 6

Growing with YouTube YouTube stats [1] >1B users 400 hrs/min of new videos (24K s/s) 80% of views from outside U.S. Schema constantly evolving Content ID, channel admin, live streams, video editing, music Developed live resharding [1] youtube.com/yt/press/statistics.html 7

Vitess 2.0 Vitess in 2014 Worked great in YouTube, but outside Users can't get past build step Custom patched MySQL No docs for setting up a deployment Along comes Kubernetes Like open-source Borg Vitess in 2015 Bring-your-own MySQL 5.6 Docker images Out-of-the-box deployment config Runs on any cloud platform supported by Kubernetes (AWS, Azure, GCP, ) Lots more documentation Step-by-step guides 8

Cloud-Native Computing

Cloud Native Computing Foundation (cncf.io) Distributed systems paradigm Container packaged Dependency management Resource isolation Dynamically scheduled Increase utilization Simplify operations Microservices-oriented Distributed applications Service endpoints 10

Kubernetes (κυβερνήτης) kubernetes.io Provides glue for distributed apps Dynamic scheduling Declarative deployment config Service discovery High-availability replica pools Rolling updates Component grouping/metadata Abstracts cloud-platform-specific pieces VM instance creation and config Networking config External load balancers Persistent storage volumes (PD, EBS) 11

Cloud-Native MySQL

Pets vs. Cattle [1] Your servers might be pets if... You can log into them by hostname or IP. You load data onto them and tell them what to do. You try to fix them when they go down. Your app knows which servers to send which queries to. You know when your last master failover was. Your servers might be cattle if... You know only that a bunch of them are out there, somewhere. They go off and join the herd without being told to. You wait for others to take over their jobs when they go down. Your app throws queries over a magic wall and results appear. You have a monitoring graph of failovers per day. [1] Noah Slater, blog.engineyard.com/2014/pets-vs-cattle 13

Dynamic Scale-Out Scale-out by adding more cattle to the herd $ kubectl create -f vttablet.yaml Dynamic scheduling means you don't worry about... What server is this going to be launched on? How is it going to get a snapshot of existing data? How is it going to find and connect to the master? How are app servers going to find out it exists? With live resharding, it even works for scaling master traffic. 14

Query Routing as a Service Separation of concerns App doesn't know anything about cluster topology MySQL doesn't know it's inside Kubernetes Vitess connects everything Distributed Vitess components Use service discovery to find each other Communicate over defined RPC APIs 15

Vitess Architecture

Vitess Components app server vtctld etcd shard vttablet app server mysqld app server vtgate master vtgate vttablet vttablet vttablet vttablet batch job mysqld mysqld mysqld mysqld App Vitess replicas batch replicas 17

Vitess Concepts Vitess range custom unsharded Keyspace -80 80-0 1 0 Shard master master master master master Tablet replica replica replica replica replica Tablet batch batch batch batch batch Tablet 18

Range-Based Sharding Basic Hashing Consistent Hashing User ID Shard User ID Keyspace ID Shard... 1234 1235 1236... 0 1 2... 1234 1235 1236...... 7F FF FF FF 80 00 00 00 80 00 00 01... -40 40-80 80- cursor = conn.cursor('test_keyspace', 'replica', keyspace_ids=[my_hash(user_id)]) cursor.execute( 'SELECT message FROM messages WHERE user_id=%(user_id)s ORDER BY time_created_ns', {'user_id': user_id}) return [row[0] for row in cursor.fetchall()] 19

Transparent Live Resharding

Vitess Resharding User ID Keyspace ID Shard Key Range Before... 1234 1235 1236...... 7F FF FF FF 80 00 00 00 80 00 00 01... -40 40-80 80-00 00 00 00-3F FF FF FF 40 00 00 00-7F FF FF FF 80 00 00 00 - FF FF FF FF User ID Keyspace ID Shard Key Range After... 1234 1235 1236...... 7F FF FF FF 80 00 00 00 80 00 00 01... -40 40-80 80-C0 00 00 00 00-3F FF FF FF 40 00 00 00-7F FF FF FF 80 00 00 00 - BF FF FF FF C0- C0 00 00 00 - FF FF FF FF 21

Transparent to the Application The app has no knowledge of what shards exist. The app keeps running normally during resharding. def my_hash(user_id): m = hashlib.md5() m.update(uint64.pack(user_id)) return m.digest()[:8] cursor = conn.cursor('test_keyspace', 'replica', keyspace_ids=[my_hash(user_id)]) cursor.execute( 'SELECT message FROM messages WHERE user_id=%(user_id)s ORDER BY time_created_ns', {'user_id': user_id}) return [row[0] for row in cursor.fetchall()] 22

Live Migration Old and new shards overlap during migration. Old Shards Running New Shards Running DB Read Availability DB Write Availability DB Write Downtime DB Write Availability < 5 seconds 23

Masters are cattle too Transparent Live Resharding means you can scale master traffic too, by adding cattle. When resharding stops being scary You don't have to predict and provision for years of growth. Provision for good utilization. Start small and scale out as needed. Cool down hot shards one at a time. 24

Resharding Workflow vitess.io/user-guide/sharding-kubernetes.html

Prepare Schema Initial sharding Add Keyspace ID column Populate along with new rows Backfill Keyspace ID for existing rows Example: Multi-tenant Guestbook (vitess.io/getting-started/) CREATE TABLE messages ( page BIGINT(20) UNSIGNED, time_created_ns BIGINT(20) UNSIGNED, keyspace_id BIGINT(20) UNSIGNED, message VARCHAR(10000), PRIMARY KEY (page, time_created_ns) ) ENGINE=InnoDB 26

Provision New Shards Moo $ kubectl create -f vttablet.yaml 27

Copy Data Split Clone Pauses replication on a backup slave So it's consistent with a known GTID set Streams rows to new shards Doesn't use extra disk space on source shard $ vtworker SplitClone --strategy=-populate_blp_checkpoint test_keyspace/0 28

Filtered Replication Vitess annotates DMLs with the Keyspace ID New shards subscribe to filtered replication stream Let new shards catch up to old shard master INSERT INTO messages (page,...) VALUES (...) -40 40-80 Filtered Replication 80-C0 80- C0-29

Verify Data Integrity Split Diff Pauses replication on backup slave in old shard Pauses filtered replication on new shards At the equivalent GTID set Performs a row-by-row comparison Also detects rows only present on one side $ vtworker SplitDiff test_keyspace/0 30

Shard Migration Migrate non-master traffic to new shards $ vtctlclient MigrateServedTypes test_keyspace/0 replica Migrate master traffic to new shards $ vtctlclient MigrateServedTypes test_keyspace/0 master 31

Scaling Benchmarks

Scaling Writes by adding Shards 33

Scaling Reads by adding Replicas 34

Vitess Roadmap

Vitess 2.0.0 Stable releases API freeze (no breaking changes) Release changelogs (github.com/youtube/vitess/releases) Versioned Docker images (hub.docker.com/u/vitess/) What's new in 2.0 Deployment configs for Kubernetes 1.0 Users reported success on both AWS and Google Cloud Platform Official client libraries for Java, Python, PHP, Go, and Hadoop MySQL 5.6 support Built-in cloud backup/restore HTTP/2-based grpc protocol (grpc.io) 36

Future Plans Drop-in drivers for JDBC, PDO, PEP 249 Already have Go driver for database/sql Cross-shard joins/aggregations Automatic master election Automated out-of-band schema changes 37

Resources Try Vitess vitess.io/getting-started/ vitess.io/user-guide/sharding-kubernetes.html Contribute github.com/youtube/vitess Cloud Native Computing Foundation cncf.io Kubernetes kubernetes.io Contact Us vitess@googlegroups.com Get Updates groups.google.com/d/forum/vitess-announce