Sei sulla pagina 1di 60

Philip Norman & Sunil Shah

SCALING LIKE
TWITTER WITH
APACHE MESOS

© 2015 Mesosphere, Inc. All Rights Reserved. 1


MODERN INFRASTRUCTURE

Dan the Datacenter Operator


Alice the Application Developer
Doesn’t sleep very well
Finds setting up infrastructure tedious
Loves automation
Wants her application to be deployed
Wants to control what runs in his as quickly as possible
datacenter

© 2015 Mesosphere, Inc. All Rights Reserved. 2


Modern Infrastructure

3 TENETS

Clean separation of No more 3am wake Easy programmatic


responsibilities ups deployment

© 2015 Mesosphere, Inc. All Rights Reserved. 3


Modern Infrastructure

CLEAN
Now

SEPARATION - With Mesos, all the nodes


are provisioned exactly the
Before same (but may have
- Dan cares about his heterogenous hardware).
hardware and Alice’s
software that runs on it
- Dan doesn’t care what
software is deployed since
- Alice cares about her applications are well
software and what encapsulated.
hardware Dan provides

- Alice doesn’t care where


her software is deployed
because it’s easy enough to
scale up and down.

© 2015 Mesosphere, Inc. All Rights Reserved. 4


Modern Infrastructure

NO MORE Now

3AM WAKE
- Mesos and Marathon
monitor running tasks.

UPS
- If a task fails or is lost (due
Before to a machine going offline),
Mesos communicates that
- Dan had to react every time
to Marathon.
an application or machine
went down.
- Marathon restarts the
application.

- Dan gets to sleep


peacefully!

© 2015 Mesosphere, Inc. All Rights Reserved. 5


Modern Infrastructure

EASY Now
PROGRAMMATIC - Dan provides Alice with her
DEPLOYMENT own instance of Marathon
that makes it hard for her
Before
to take down someone
- Servers were handcrafted. else’s application.

- Deploying new or updated - Running applications are


software would require isolated from each other by
oversight and involvement Mesos.
from both Alice and Dan.

- Marathon offers a nice API


that allows Alice to easily
deploy new versions safely.

© 2015 Mesosphere, Inc. All Rights Reserved. 6


Apache Mesos

LAYER OF ABSTRACTION

© 2015 Mesosphere, Inc. All Rights Reserved. 7


Apache
Apache Mesos
Mesos
INTRODUCTION

Apache Mesos is a cluster resource manager.

It handles:
Aggregating resources and offering them to schedulers
Launching tasks (i.e. processes) on those resources
Communicating the state of those tasks back to schedulers

© 2015 Mesosphere, Inc. All Rights Reserved. 8


PRODUCTION CUSTOMERS AND MESOS USERS

Government Agencies

© 2015 Mesosphere, Inc. All Rights Reserved. 9


MESOS:
ORIGINS

© 2015 Mesosphere, Inc. All Rights Reserved. 10


THE BIRTH OF MESOS

TWITTER TECH TALK


APACHE INCUBATION
The grad students working on Mesos
Mesos enters the Apache Incubator.
give a tech talk at Twitter.

Spring 2009 September 2010

March 2010 December 2010

CS262B MESOS PUBLISHED

Ben Hindman, Andy Konwinski and Mesos: A Platform for Fine-Grained


Matei Zaharia create “Nexus” as their Resource Sharing in the Data Center is
CS262B class project. published as a technical report.

© 2015 Mesosphere, Inc. All Rights Reserved. 11


TECHNOLOGY VISION

Sharing resources between batch


What does an operating system provide?
processing frameworks
Resource management
Hadoop
Programming abstractions
MPI
Security
Spark
Monitoring, debugging, logging

© 2015 Mesosphere, Inc. All Rights Reserved. 12


MESOS FUNDAMENTALS

ARCHITECTURE

© 2015 Mesosphere, Inc. All Rights Reserved. 13


MESOS FUNDAMENTALS

ARCHITECTURE

Agents advertise resources to Master


Master offers resources to Scheduler
Scheduler rejects/uses resources
Agents report task status to Master

© 2015 Mesosphere, Inc. All Rights Reserved. 14


MESOS FUNDAMENTALS

ARCHITECTURE

Agents advertise resources to Master


Master offers resources to Scheduler
Scheduler rejects/uses resources
Agents report task status to Master

© 2015 Mesosphere, Inc. All Rights Reserved. 15


MESOS FUNDAMENTALS

ARCHITECTURE

Agents advertise resources to Master


Master offers resources to Scheduler
Scheduler rejects/uses resources
Agents report task status to Master

© 2015 Mesosphere, Inc. All Rights Reserved. 16


MESOS FUNDAMENTALS

ARCHITECTURE

Agents advertise resources to Master


Master offers resources to Scheduler
Scheduler rejects/uses resources
Agents report task status to Master

© 2015 Mesosphere, Inc. All Rights Reserved. 17


MESOS FUNDAMENTALS

ARCHITECTURE

Agents advertise resources to Master


Master offers resources to Scheduler
Scheduler rejects/uses resources
Agents report task status to Master

© 2015 Mesosphere, Inc. All Rights Reserved. 18


KEEP IT STATIC

A naive approach to handling varied app


requirements: static partitioning.

This can cope with heterogeneity, but is


very expensive.

time

© 2015 Mesosphere, Inc. All Rights Reserved. 19


KEEP IT STATIC

Maintaining sufficient headroom to


handle peak workloads on all partitions
leads to poor utilisation overall.

time

© 2015 Mesosphere, Inc. All Rights Reserved. 20


SHARED RESOURCES

Multiple frameworks can use the same


cluster resources, with their share
adjusting dynamically.

time

© 2015 Mesosphere, Inc. All Rights Reserved. 21


TWITTER &
MESOS

© 2015 Mesosphere, Inc. All Rights Reserved. 22


THE BIRTH OF MESOS

TWITTER TECH TALK


APACHE INCUBATION
The grad students working on Mesos
Mesos enters the Apache incubator.
give a tech talk at Twitter.

Spring 2009 September 2010

March 2010 December 2010

CS262B MESOS PUBLISHED

Ben Hindman, Andy Konwinski and Mesos: A Platform for Fine-Grained


Matei Zaharia create Nexus as their Resource Sharing in the Data Center is
CS262B class project. published as a technical report.

© 2015 Mesosphere, Inc. All Rights Reserved. 23


MESOS REALLY HELPS

● Former Google engineers at Twitter


thought Mesos could provide the same
functionality as Borg.

● Mesos actually works pretty well for long


running services.

© 2015 Mesosphere, Inc. All Rights Reserved. 24


MESOS WITH
MARATHON IN
PRODUCTION

© 2015 Mesosphere, Inc. All Rights Reserved. 25


Mesos with Marathon in Production

WHAT IS MARATHON?

Service scheduler for Mesos


init.d for long-running apps
Your own private PaaS

© 2015 Mesosphere, Inc. All Rights Reserved. 26


Mesos with Marathon in Production

WHAT IS MARATHON?

© 2015 Mesosphere, Inc. All Rights Reserved. 27


Mesos with Marathon in Production

USEFUL MARATHON FEATURES

Start, stop, scale, update apps


Highly available, no SPoF
Native Docker support
Powerful Web UI
Fully featured REST API
Pluggable event bus
Artifact staging

© 2015 Mesosphere, Inc. All Rights Reserved. 28


Mesos with Marathon in Production

USEFUL MARATHON FEATURES: DEPLOY LIKE FACEBOOK

Application versioning
Rolling deploy / restart
Deployment strategies

© 2015 Mesosphere, Inc. All Rights Reserved. 29


Mesos with Marathon in Production

USEFUL MARATHON FEATURES: DEPLOY LIKE A TELCO

Application versioning
Hot/hot new/old clusters
Authentic scale testing
Manual *and* automated testing

© 2015 Mesosphere, Inc. All Rights Reserved. 30


MESOS WITH
MARATHON IN
ACTION

© 2015 Mesosphere, Inc. All Rights Reserved. 31


© 2015 Mesosphere, Inc. All Rights Reserved. 32
© 2015 Mesosphere, Inc. All Rights Reserved. 33
© 2015 Mesosphere, Inc. All Rights Reserved. 34
© 2015 Mesosphere, Inc. All Rights Reserved. 35
© 2015 Mesosphere, Inc. All Rights Reserved. 36
© 2015 Mesosphere, Inc. All Rights Reserved. 37
© 2015 Mesosphere, Inc. All Rights Reserved. 38
© 2015 Mesosphere, Inc. All Rights Reserved. 39
© 2015 Mesosphere, Inc. All Rights Reserved. 40
© 2015 Mesosphere, Inc. All Rights Reserved. 41
© 2015 Mesosphere, Inc. All Rights Reserved. 42
Mesos with Marathon in Action

TASK FAILURE

© 2015 Mesosphere, Inc. All Rights Reserved. 43


© 2015 Mesosphere, Inc. All Rights Reserved. 44
© 2015 Mesosphere, Inc. All Rights Reserved. 45
© 2015 Mesosphere, Inc. All Rights Reserved. 46
© 2015 Mesosphere, Inc. All Rights Reserved. 47
Mesos with Marathon in Production

SERVICE DISCOVERY

How do my applications discover each other?

Two main service discovery mechanisms:


1.DNS based (Mesos-DNS)
2.HAProxy based (Marathon-lb)

© 2015 Mesosphere, Inc. All Rights Reserved. 48


Service Discovery

MESOS-DNS

● Ingests cluster state


periodically.

● Uses cluster state to


generate DNS records for
all running Mesos tasks.

● Services query DNS server


to discover IP address and
port of other services.

● Primarily used for internal


service discovery.

● No extra configuration
required!

© 2015 Mesosphere, Inc. All Rights Reserved. 49


Service Discovery

MARATHON-LB

● Ingests state of running


Marathon applications.

● Regenerates HAProxy
configuration.

● Supports virtual hosts!

● Can be used for both


internal and external
service discovery.

● Must add
HAPROXY_GROUP and
HAPROXY_0_VHOST
variables to your
marathon.json.

© 2015 Mesosphere, Inc. All Rights Reserved. 50


Mesos as the Datacenter Kernel

HOW TO DEPLOY A MESOS CLUSTER (THE HARD WAY)

Using chef/puppet/ansible (or a reliable intern)


Install ZooKeeper and Mesos
Install your scheduler (Marathon)
Deploy some long-running services.
See https://open.mesosphere.com/getting-started/tools/ for more docs

© 2015 Mesosphere, Inc. All Rights Reserved. 51


Mesos as the Datacenter Kernel

HOW TO DEPLOY A MESOS CLUSTER (OUR WAY)

Visit http://mesosphere.com
Hit the ‘Get Started’ button

© 2015 Mesosphere, Inc. All Rights Reserved. 52


MESOS AS Services &
Containers

THE
DATACENTER
KERNEL
Mesosphere
DCOS

Existing
Infrastructure

© 2015 Mesosphere, Inc. All Rights Reserved. 53


Mesos as the Datacenter Kernel

JENKINS: BUILD RESOURCE POOLING

Jenkins on Mesos allows you to share build resources between multiple Jenkins
masters.

PayPal does this with hundreds of Jenkins masters


Between them, they use less than a hundred build slaves to service several
thousand developers.
Combining Jenkins with a PaaS like Marathon or Kubernetes allows you to practice
easy continuous deployment.

© 2015 Mesosphere, Inc. All Rights Reserved. 54


An example continuous
deployment pipeline
using Mesos, Marathon,
Docker and Jenkins on
Mesos.
© 2015 Mesosphere, Inc. All Rights Reserved. 55
CONTINUOUS
DELIVERY
DEMO

© 2015 Mesosphere, Inc. All Rights Reserved. 56


Mesos as the Datacenter Kernel

KUBERNETES ON MESOS

© 2015 Mesosphere, Inc. All Rights Reserved. 57


Mesos as the Datacenter Kernel

KUBERNETES ON MESOS

© 2015 Mesosphere, Inc. All Rights Reserved. 58


Mesos as the Datacenter Kernel

BIG DATA ON MESOS

Mesos was built for and is great for running big data workloads:
Chronos (time scheduled jobs)
Spark
Cassandra
Kafka
Hadoop/YARN (via Myriad)

© 2015 Mesosphere, Inc. All Rights Reserved. 59


QUESTIONS?
THANK YOU!
Come and talk to us!
● Email us at philip@mesosphere.io, sunil@mesosphere.io
● Slides will be up at http://mesosphere.github.io/presentations

60

Potrebbero piacerti anche