Vitess on Kubernetes followed by a demo of VReplication Jiten - - PowerPoint PPT Presentation

vitess on kubernetes followed by a demo of vreplication
SMART_READER_LITE
LIVE PREVIEW

Vitess on Kubernetes followed by a demo of VReplication Jiten - - PowerPoint PPT Presentation

Vitess on Kubernetes followed by a demo of VReplication Jiten Vaidya jiten@planetscale.com A word about me ... Jiten Vaidya - Managed teams that operationalized Vitess at Youtube CEO at PlanetScale Founded in early 2018 to help


slide-1
SLIDE 1

Vitess on Kubernetes …followed by a demo of VReplication

Jiten Vaidya jiten@planetscale.com

slide-2
SLIDE 2

A word about me ...

Jiten Vaidya - Managed teams that operationalized Vitess at Youtube CEO at PlanetScale Founded in early 2018 to help operationalize Vitess

  • Sugu Sugumaran (CTO, Vitess community leader)

Offerings

  • Open Source Vitess Support
  • Custom Vitess Development
  • Kubernetes Deployment Manager
  • Cross-cloud DBaaS
slide-3
SLIDE 3

Show of hands ...

  • How many of you know what Vitess is?
  • How many of you are facing scaling problems?
  • How many of you want to run mysql in Cloud?
slide-4
SLIDE 4

What does Vitess solve?

  • Database Scalability
  • MySQL Guardrails
  • Operation in Cloud
slide-5
SLIDE 5

Vitess Architecture

shard vtgate app server app server app server mysqld vttablet master vtgate big data Vitess lockserver mysqld vttablet mysqld vttablet replicas mysqld vttablet big data replicas mysqld vttablet vtctld App

slide-6
SLIDE 6

Major users using Vitess

In production Evaluating

Quiz of Kings

slide-7
SLIDE 7

Vtgate in Kubernetes

  • Stateless proxy
  • Accepts connections as a MySQL

compatible server + over GRPC

  • Supports an http endpoint + Web

UI for status

  • Computes target shards
  • Sends queries to vttablets for

targeted shards

  • Receives, collates and serves

response to application

  • Vtgates can be created as load

increase

  • Start n vtgates as a Replica Set
  • For co-located workloads start one

vtgate per node and expose with a ClusterIP

slide-8
SLIDE 8

Vtctld in Kubernetes

  • Vitess Control Plane
  • Serves a Web UI

○ Operational commands ○ Status ○ Topology browser

  • Serves an API over GRPC

○ Used by vtctlclient tool

  • Supports resharding workflows
  • Start one or two vtctld processes

per cell

  • Start them as a Deployments
  • Expose them behind a Service
slide-9
SLIDE 9

lockserver (etcd) in Kubernetes

  • Knits the Vitess cluster together
  • Backing store for metadata

○ Service discovery ○ Topology ○ VSchema

  • Not used for query serving
  • Needed for any change in

topology ○ Add a keyspace ○ Add a shard to keyspace ○ Add a tablet to a shard ○ Change master for a shard

  • One global cluster
  • One cluster per cell (optional)
  • Use etcd-operator to spin out a

cluster

  • Expose etcd cluster behind a

Service

slide-10
SLIDE 10

Tablet (vttablet + mysqld) in Kubernetes

  • Vitess Tablet is a combination
  • f a mysqld instance and a

corresponding vttablet process

  • Each tablet requires a unique

id in Vitess cluster

  • Tablets can be of type: master,

replica, rdonly

  • Tablets of type “replica” can

be promoted to master and should have low replica lag

  • 2 containers in the same pod
  • Communicate over Unix socket
  • Unix socket created in Shared

Volume

  • Local Persistent Volume for

data

  • One master, 2 replicas with

semi-sync replication enabled for high availability

  • Replicas should not be

co-located with other members

  • f shard ( Anti-Affinity )
slide-11
SLIDE 11

Authentication/Secrets management

  • What secrets are needed?

○ Application -> Vtgate authentication ○ Vttablet -> mysqld authentication for various roles that Vitess supports (app, dba, replication, filtered replication etc). ○ TLS certs and keys for GRPC traffic over TLS (optional) ○ TLS certs and keys for binary logs over TLS (optional) ○ TLS certs and keys for client authorization and authentication over TLS (optional)

  • Use Kubernetes Secrets and mount them in pods
slide-12
SLIDE 12

High Availability

  • Planned reparent

○ Coordinated via lockserver ○ Existing transactions are allowed to complete ○ New transactions are buffered by vtgate ○ New master is made writable ○ Replicas are made slaves of the new master ○ Query serving is resumed

  • Unplanned reparent

○ Orchestrator ○ TabletExternallyReparented

  • Resharding

○ No interruption to query traffic during resharding

slide-13
SLIDE 13

Supporting multiple cells

  • Vitess cell is the equivalent of a failure domain

(e.g. AWS availability zones or regions)

  • Not necessarily the same as Kubernetes failure

domain.

  • Choice to use global lockserver cluster OR use
  • ne lockserver cluster per cell.
  • Global lockserver cluster typically outside of

Kubernetes.

  • Expose lockserver behind a service definition.
  • If using etcd use etcd-operator to start per cell

cluster.

slide-14
SLIDE 14

Vitess clusters spanning Kubernetes clusters

  • Global lockserver cluster should be outside of

Kubernetes

  • While creating each cell designate which

Kubernetes cluster it resides in

  • Must have a non-overlapping ip space and all

addresses must be routable.

  • pod to pod communication

○ Needed for mysql replication and query serving ○ Achieved by Peering and Routing

slide-15
SLIDE 15

Part II: Vitess in Action

  • Vitess super power: filtered replication

aka VReplication

  • Ability to consume binary replication log,

and apply sharding or other logic to it

  • Shard splits (aka resharding)
  • Sharded Materialized Views
slide-16
SLIDE 16

app server vtgate mysqld Vttablet (Shard -)

Splitting a Shard in Vitess

Step 1 - Vitess in-front of app 1 shard.

slide-17
SLIDE 17

Filtered Replication

17

app server vtgate mysqld Vttablet (Shard 0) mysqld Vttablet (Shard 00-80) mysqld Vttablet (Shard 80-FF)

Live Resharding

Step 2 - Split Shard

slide-18
SLIDE 18

app server vtgate mysqld Vttablet (Shard 00-80) mysqld Vttablet (Shard 80-FF)

Live Resharding

Step 3 - Split Shard

slide-19
SLIDE 19

Hot off the presses ...

… Sharded Materialized Views (Ability to shard using more than one sharding key using replication streams) M shards using key1 -> N shards using key2 M * N replication streams

slide-20
SLIDE 20

Materialized view example

slide-21
SLIDE 21

Demo

user id name

  • rder

id uid pid mname merchant name lookup unsharded product Id description user sharded merchant sharded name_user_idx name uid

slide-22
SLIDE 22

Questions?

jiten@planetscale.com