powering microservices with mongodb, docker, kubernetes & kafka – mongodb europe 2016

48
Powering Microservices with Docker, Kubernetes & Kafka Andrew Morgan MongoDB Product Marketing @andrewmorgan

Upload: andrew-morgan

Post on 07-Jan-2017

1.627 views

Category:

Software


0 download

TRANSCRIPT

Page 1: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

Powering Microservices with Docker, Kubernetes & KafkaAndrew MorganMongoDB Product Marketing@andrewmorgan

Page 2: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Agenda

What, Why, How?

Microservices01Kubernetes, Mesos,…

Orchestration03DockerKafka

Containers02

Why, How?

MongoDB04Who, Why?

Use Cases06When to Use05

Page 3: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

Microservices

Page 4: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Why Use Microservices? (tl;dr WebScale)

Team = Components

No committees

EmpowerBuild MVP quickly

SpeedSimple

componentsIsolated impact

MaintainRapid iterationsReact to market

ChangeProductTeam

Scale

Page 5: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

1990s & Earlier

MonolithicCross-TeamTight Coupling

Small Chang

e

Huge Impac

t

System

Retests

Page 6: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

2000sSOA

CoordinationLooser

CouplingSystem Retests

Page 7: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

2010sMicroservices

DecoupledIndependent

DevIsolated Impact

Page 8: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Microservices Example

Twitter

IngestGoogl

e+ Ingest

Snapchat

Ingest

Feed merge

Facebook

Ingest

Page 9: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Microservices Example

Twitter

Ingest

Snapchat

Ingest

Feed merge

Facebook

Ingest

Page 10: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Microservices Example

Twitter

Ingest

Snapchat

Ingest

Feed merge

Facebook

Ingest

Page 11: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Microservices Example

Twitter

Ingest

Snapchat

Ingest

Feed merge

Facebook

Ingest

Whatsapp

Ingest

Page 12: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Microservices Example

Twitter

Ingest

Snapchat

Ingest

Feed merge

Facebook

Ingest

Whatsapp

Ingest

Snapchat

IngestSnapchat

Ingest

Page 13: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Alternate Microservices Example

• Much larger Microservices1. User Account2. Product Catalog3. Inventory4. Orders

• Best practice is each microservice has its own database

Page 14: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

“ Conway’s Law1967

Any organization that designs a system will inevitably produce a design whose structure is a copy of the organization's communication structure.”

Page 15: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Development Teams

Page 16: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

Containers

Page 17: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Containers – Powering Microservices

Real world shipping containers• Road, rail & sea• Contents untouched• Ubiquitous & standardized• Simple• Contents protected• Constraints

Page 18: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Containers – Powering Microservices

Software containers• 1 image -> Many

containers• Laptop, DC, cloud• Dev, QA, production, support

• Simple, efficient• Isolation• Constraints

Page 19: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

VMs vs. ContainersVM VMVM

Bare MetalHost Operating System

HypervisorGuest OSLibraries

AppsService

Guest OSLibraries

AppsService

Guest OSLibraries

AppsService

Container ContainerContainer

Bare MetalHost Operating System

Docker EngineLibraries

LibrariesApps

LibrariesApps

Service ServiceService

Page 20: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

VMs vs. ContainersVM VMVM

Bare MetalHost Operating System

HypervisorGuest OSLibraries

AppsService

Guest OSLibraries

AppsService

Guest OSLibraries

AppsService

Container ContainerContainer

Bare MetalHost Operating System

Docker EngineLibraries

LibrariesApps

LibrariesApps

Service ServiceService

Page 21: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

VMs vs. ContainersVM VMVM

Bare MetalHost Operating System

HypervisorGuest OSLibraries

AppsService

Guest OSLibraries

AppsService

Guest OSLibraries

AppsService

Container ContainerContainer

Bare MetalHost Operating System

Docker EngineLibraries

LibrariesApps

LibrariesApps

Service ServiceService

Page 22: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Docker

• Simple to use• 100K+ images on Docker

Hub• Build images from images• Platforms• Linux, OS X, Windows• Laptop, VM, Cloud,…• Cloud services

Page 23: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Run MongoDB

docker run -d mongo

Page 24: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Security

Opportunities

• Isolation• Constrain resources• Narrow roles• Keep images/containers

current• root: so restrict access

Page 25: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Title only

Page 26: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Title only

Page 27: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Microservice Architectures Built on Containers

Many small, focused containers -> sophisticated services

• Well defined APIs• Independent languages &

libraries• Modular: easy maintenance

+ reuse• Fault tolerant• Scalable

Page 28: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Connecting the Microservices – Apache Kafka

Producer987

123...

Topic A

Consumer

Page 29: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Connecting the Microservices – Apache Kafka

Producer

987

123...

Topic A

Consumer

Producer Consumer

Page 30: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Connecting the Microservices – Apache Kafka

Producer

987

123...Partition 0

Topic A

Consumer

Producer Consumer

435

123...Partition 1

Page 31: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Connecting the Microservices – Apache Kafka

Producer

LEADER

Topic A / Partition 0

Broker 1

FOLLOWER

Topic A / Partition 1

FOLLOWER

Topic A / Partition 0

Broker 2

LEADER

Topic A / Partition 1

Page 32: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Connecting the Microservices – Apache Kafka

Producer

Producer

Producer

987

123...

Partition 0

435

123...

Partition 1

732

123...

Partition N

Topic A

Topic B

765

123...

Partition 0

New Old

Consumer

Consumer

Page 33: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

Orchestration

Page 34: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Orchestration

Automated deployment, connecting, and maintenance of multiple containers

• Provision hosts• Containers

• Instantiate• Reschedule• Link• Scale Out/In

• Expose services

Page 35: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Kubernetes

Created by Google, feature-rich and widely adopted

• Deployment and ‘replication’• On-line scale out/in• Rolling upgrades• High Availability• Persistence• Ports• Load balancing• Google Compute Engine

Page 36: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Apache Mesos

10,000s of physical servers; used by Twitter, Airbnb & Apple

• Code (“frameworks) vs. declarative• Less feature rich than Kubernetes• Kubernetes as a Mesos

framework• Foundation for distributed

systems• Apache Aurora, Chronos, Marathon

Page 37: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Choosing an Orchestration Framework

• What you have:• Skills?• DevOps frameworks?• Number of hosts?• Bare metal, VMs, or cloud?

• Lifecycle• Features• Automated High Availability?• Grouping and load balancing?• As a service??

Page 38: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

MongoDB

Page 39: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Why MongoDB is a Good Fit For Microservices

ScalabilityMonitoring&

AutomationRedundancyFlexible

DataModel

Simplicity

Page 40: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

Orchestrating MongoDB Using Kubernetes

Distributed, stateful application

• Persistent volumes• External IP addresses for internal comms• Init MongoDB replica set• Monitor• Backup

Page 41: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016
Page 42: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016
Page 43: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

When to use Microservices

Page 44: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

When to use Microservices

Page 45: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

Use Cases

Page 46: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

MongoDB & Microservices in the Wild

Page 47: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016

#MDBW16

References

• Enabling Microservices – Containers & Orchestration Explainedhttps://www.mongodb.com/collateral/microservices-containers-and-orchestration-explained

• Microservices: The Evolution of Building Modern Applicationshttps://www.mongodb.com/collateral/microservices-the-evolution-of-building-modern-applications

• Data Streaming with Apache Kafka & MongoDBhttps://www.mongodb.com/collateral/data-streaming-with-apache-kafka-and-mongodb

Page 48: Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Europe 2016