operating microservices @unterstein @dcos @bedcon...

47
1 Operating microservices with Apache Mesos and DC/OS @unterstein @dcos @bedcon #bedcon

Upload: lythuan

Post on 18-Mar-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

1

Operating microservices with Apache Mesos and DC/OS

@unterstein @dcos @bedcon #bedcon

Page 2: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 2

Johannes UntersteinSoftware Engineer @Mesosphere

@unterstein

@unterstein.mesosphere

Page 3: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 3

In the beginning there was a big

Monolith

Page 4: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

Hardware

Operating System

Application

4

COMPUTERS

Page 5: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

Hardware

Operating System

Web Application

5

INTERNET- Remote Users!

Page 6: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

Web App

Hardware

Operating System

6

DISTRIBUTION- Horizontal Scale- Fault Tolerance- Availability- Load Balancing

Operating System

Operating System

Hardware Hardware

Web App Web App

Page 7: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

Service Service Service

Web App Web App Web App

Hardware

Operating System

7

SERVICE-ORIENTEDARCHITECTURE

- Separation of concerns

- Optimization of bottlenecks

- Smaller teams- API Contracts- Data replication- Complicated

provisioning- Dependency

management

Operating System

Operating System

Hardware Hardware

Page 8: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

Service Service Service

Web App Web App Web App

Machine

Operating System

8

HARDWAREVIRTUALIZATION

- Fast provisioning- Isolation- Portability- Utilization- Configuration

Management- Virtual Networking- Credential

management

Operating System

Operating System

Infrastructure

Machine Machine

Page 9: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

Operating System

Operating System

Operating System

ServiceApp ServiceServiceAppApp

9

MICROSERVICES- Polyglot- Single Responsibility- Smaller Teams- Utilization- Machine

types/groups- Dependency hell

Machine

Infrastructure

Machine Machine

ServiceService ServiceServiceServiceService

Page 10: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

noun | ˈmīkrō/ /ˈsərvəs/ :

an approach to application development in which a large application is built as a suite of modular services. Each module supports a specific business goal and uses a simple, well-defined interface to communicate with other modules.*

Microservices are designed to be flexible, resilient, efficient, robust, and individually scalable.

*From whatis.com

OVERVIEW

Page 11: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

Operating System

Operating System

Operating System

ServiceApp ServiceServiceAppApp

11

MICROSERVICES- Polyglot- Single Responsibility- Smaller Teams- Utilization- Machine

types/groups- Dependency hell

Machine

Infrastructure

Machine Machine

ServiceService ServiceServiceServiceService

Page 12: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

Run everything in containers!

Page 13: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

ServiceApp ServiceServiceAppApp

OS

13

CONTAINERS- Rapid deployment- Dependency

vendoring- Container image

repositories- Spreadsheet

scheduling

OS OS

Machine

Infrastructure

Machine Machine

Container Runtime Container Runtime Container Runtime

ServiceService ServiceServiceServiceService

Page 14: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

CONTAINER SCHEDULING

14

Page 15: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

RESOURCE MANAGEMENT

15

Page 16: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

SERVICE MANAGEMENT

16

Page 17: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 17

CONTAINERSCHEDULING

RESOURCE MANAGEMENT

SERVICE MANAGEMENT

- Load Balancing- Readiness Checking

CONTAINER ORCHESTRATION

Page 18: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 18

CONTAINERSCHEDULING

- Placement- Replication/Scaling- Resurrection- Rescheduling- Rolling Deployment- Upgrades- Downgrades- Collocation

RESOURCE MANAGEMENT

- Memory- CPU- GPU- Volumes- Ports- IPs- Images/Artifacts

SERVICE MANAGEMENT

- Labels- Groups/Namespaces- Dependencies- Load Balancing- Readiness Checking

CONTAINER ORCHESTRATION

Page 19: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

Orc

hest

ratio

n

19

Machine Infrastructure

Web Apps & Services

Scheduling

Resource Management

Container Runtime

Machine & OS

Service Management

CONTAINERORCHESTRATION

Machine & OS Machine & OS

Container Runtime Container Runtime

Page 20: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 20

MapReduce is crunching Data

Meanwhile...

Page 21: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 21

DATA PROCESSING AT HYPERSCALE

EVENTSUbiquitous data streams from connected devices

INGEST

Apache Kafka

STORE

Apache Spark

ANALYZE

Apache Cassandra

ACT

Akka

Ingest millions of events per second

Distributed & highly scalable database

Real-time and batch process data

Visualize data and build data driven applications

DC/OS

Sensors

Devices

Clients

Page 22: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 22

DATA PROCESSING AT HYPERSCALE

EVENTSUbiquitous data streams from connected devices

INGEST

Apache Kafka

STORE

Apache Spark

ANALYZE

Apache Cassandra

ACT

Akka

Ingest millions of events per second

Distributed & highly scalable database

Real-time and batch process data

Visualize data and build data driven applications

DC/OS

Sensors

Devices

Clients

Page 23: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 23

● Apache Storm● Apache Spark● Apache Samza● Apache Flink● Apache Apex● Concord● cloud-only: AWS Kinesis,

Google Cloud Dataflow

STREAM PROCESSING

Page 24: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 24

Micro-Batching

EXECUTION MODEL

Native Streaming

Page 25: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 25

DATA PROCESSING AT HYPERSCALE

EVENTSUbiquitous data streams from connected devices

INGEST

Apache Kafka

STORE

Apache Spark

ANALYZE

Apache Cassandra

ACT

Akka

Ingest millions of events per second

Distributed & highly scalable database

Real-time and batch process data

Visualize data and build data driven applications

DC/OS

Sensors

Devices

Clients

Page 26: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 26

Datastores

Page 27: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 27

Key-Value

Data Model

GraphRelational Document● Schema● SQL ● Foreign

Keys/Joins● OLTP/OLAP

● Simple● Scalable● Cache

FilesTime-Series● Complex

relations● Social Graph● Recommend

ation● Fraud

detections

● Schema-Less● Semi-structu

red queries● Product

catalogue● Session data

Page 28: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 28

Modern datacenter

Page 29: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

Flink Cassandra µServices Spark RDB

Page 30: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

Flink Cassandra µServices Spark RDB

Page 31: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 31

A naive approach to handling varied app requirements: static partitioning.

Maintaining sufficient headroom to handle peak workloads on all partitions leads to poor utilization overall.

KEEP IT STATIC

time

Page 32: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 32

Multiple frameworks can use the same cluster resources, with their share adjusting dynamically.

SHARED RESOURCES

time

Page 33: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 33

SILOS OF DATA, SERVICES, USERS, ENVIRONMENTS

Typical Datacentersiloed, over-provisioned servers,

low utilization

Modern Datacenterautomated schedulers, workload multiplexing onto the

same machines

Industry Average12-15% utilization

Multiplexing30-40% utilization, more at some users

4X

mySQL

microservices

Cassandra

Spark/Hadoop

Kafka

Page 34: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 34

Page 35: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 35

THE BIRTH OF MESOS

TWITTER TECH TALKThe grad students working on Mesos

give a tech talk at Twitter.

March 2010

APACHE INCUBATIONMesos enters the Apache Incubator.

Spring 2009

CS262BBen Hindman, Andy Konwinski and

Matei Zaharia create “Nexus” as their CS262B class project.

MESOS PUBLISHEDMesos: A Platform for Fine-Grained

Resource Sharing in the Data Center is published as a technical report.

September 2010

December 2010

DC/OS

April 2016

Page 36: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

• A top-level Apache project• A cluster resource

negotiator• Scalable to 10,000s of

nodes• Fault-tolerant, battle-tested• An SDK for distributed apps• Native Docker support

36

Apache Mesos

Page 37: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 37

ARCHITECTUREMESOS FUNDAMENTALS

Page 38: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 38

● Default Sandbox

Simple to use, Task failures

● Persistent Volumes

Task failures, (permanent) Node failures

● Distributed File System/External Storage

Node failures, non-local writes

STORAGE OPTIONS

Page 39: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 39

Page 40: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

Datacenter Operating System (DC/OS)

Distributed Systems Kernel (Mesos)

DC/OS ENABLES MODERN DISTRIBUTED APPS

Big Data + Analytics EnginesMicroservices (in containers)

Streaming

Batch

Machine Learning

Analytics

Functions & Logic

Search

Time Series

SQL / NoSQL

Databases

Modern App Components

Any Infrastructure (Physical, Virtual, Cloud)40

Page 41: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

41

THEBASICS

DC/OS is … ● 100% open source (ASL2.0)

+ A big, diverse community● An umbrella for ~30 OSS projects

+ Roadmap and designs+ Docs, tutorials, setup installations..+ Check https://dcos.io

● Familiar, with more features+ Networking, Security, CLI, UI,

Service Discovery, Load Balancing, Packages, ...

Page 42: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 42

Best Practices

Page 43: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 43

● Deployment● Service Discovery● Monitoring● Logging

GOING TO PRODUCTION

Page 44: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved. 44

DEPLOYMENTBEST PRACTICES

● Version configurations● Private registries● Resource limits● Make it HA

Page 45: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

● Dynamic ports● Virtual IPs● DNS● Overlay networks● External tools

45

SERVICE DISCOVERYBEST PRACTICES

Page 46: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2016 Mesosphere, Inc. All Rights Reserved.

● Application metrics● Health checks● Alerting● Aggregate logs● Consistent service logs

46

MONITORING & LOGGINGBEST PRACTICES

Page 47: Operating microservices @unterstein @dcos @bedcon …bed-con.org/2017/files/slides/Unterstein-Microservices.pdf · Apache Samza Apache Flink Apache Apex Concord cloud-only: AWS Kinesis,

© 2017 Mesosphere, Inc. All Rights Reserved. 47

Questions?

Code: https://git.io/v1DjV https://git.io/vXUoy@unterstein

github.com/unterstein

@mesosphere / mesosphere.com@dcos / dcos.io / chat.dcos.io