SlideShare a Scribd company logo
Scaling MongoDB with Docker
and cgroups
Marco Bonezzi
TechnicalServicesEngineer,MongoDB
marco@mongodb.com
	
@marcobonezzi
#MDBW16
About the speaker
I am Marco Bonezzi, TSE at MongoDB
TSE = helping customers with a variety of issues
Based in Dublin, Ireland
Experience in distributed systems, high availability:
#MDBW16
How many of you have ever...
1.  … manually deployed a MongoDB replica sets or sharded clusters?
2.  ... had issues with resource allocation?
3.  ... used Docker?
4.  … used MongoDB running on Docker?
#MDBW16
We know how it feels…
Different
architectures in
Development and
Production
Co-located
MongoDB
processes
Production !=
docker run
mongodb
#MDBW16
What	are	the	pain	points?	
Deployment
Complex architectures and deployment patterns
Resource Contention
Multiple instances competing for resources
MongoDB & Docker
Combining both: network configuration, container location, other
#MDBW16
How	to	solve	this?	
Deployment
Using predefined cluster patterns
Replicating environments
Resource Control
Setting limits to key resources
MongoDB & Docker
Create once, deploy everywhere
Deploy patterns, not processes
Orchestration
Resource
Management
Automate for
scaling
#MDBW16
About	this	talk	
Patterns for successful deployments
Difference between success and failure
Orchestrating MongoDB with Docker
MongoDB cluster on AWS with containers
Patterns with Swarm and Compose
Managing container resources with cgroups
Benefits of cgroups in a MongoDB cluster
P	
S	
S
#MDBW16
Redundancy and fault tolerance
Deploy an odd number of voting members
Members ó Majority required ó Fault tolerance
High availability and resource colocation
Single member of a replica set / server
Shards as Replica Set
Ideally: primary / secondary / secondary
Deployment patterns: Replica Set and Sharded Clusters
Server 3Server 2Server 1
mongos
Primary
Primary
RS1
SecondarySecondary
Secondary
RS2
Secondary
RS3
Secondary
RS1
Primary
RS2
Secondary
RS3
Secondary
RS1
Secondary
RS2
Primary
RS3
mongos mongos
cfgsvr1 cfgsvr2 cfgsvr3
#MDBW16
Docker
•  Noun: a person employed in a port to load and unload ships (from “what
is docker” on Google)
Containers:
Isolated process in userspace
Application + dependencies
Shared kernel and libraries
Can run on any infrastructure (or
cloud)
www.docker.com
#MDBW16
44%
of orgs adopting
microservices
Why use Docker?
41%
want application
portability
13x
improvement in
release frequency
62%
MTTR on software
issues
60%
Using Docker to
migrate to cloud
Reason to run containers:
SPEED
Microservices
architectures
Efficiency Cloud
(The	Docker	Survey,	2016)
#MDBW16
Good	news:	Docker	can	help	with	this!	
Orchestration
Coordinate MongoDB containers to deploy a recommended deployment
pattern
Resource Control
Sizing each instance (and each cluster) to avoid resource contention
issues
#MDBW16
Orchestrating MongoDB with Docker
How can we use Docker for MongoDB deployments?
How can we deploy these patterns using Docker containers?
Why should we use Docker?
Our recipe:
#MDBW16
Docker	ecosystem	
Provisioning and managing your Dockerized hosts
Native clustering: turns a pool of Docker hosts into a single, virtual
Docker host.
Define a multi-container application with all of its dependencies in
a single file
S
#MDBW16
Why	Docker	Swarm?	
5x faster than
Kubernetes to spin up
a new container
7x faster than
Kubernetes to list all
running containers
Evaluating Container Platforms at
Scale
1000 EC2 instances in a cluster
What is their performance at scale?
Can they operate at scale?
What does it take to support them at scale?
https://medium.com/on-docker/evaluating-container-platforms-at-scale-5e7b44d93f2c#.k2fxds8c2
hGps://www.docker.com/survey-2016
#MDBW16
swarm-node-2
swarm-node-3swarm-node-1
Swarm multi-host networking
How each mongod process connects to other processes outside of the
host?
•  Swarm overlay container-to-container network
•  Using the hostname defined in the Compose file
#MDBW16
Swarm filters to build our patterns
Constraint filters
Mark each mongod container with a label:
“role=mongod”
“replset=rs1”
#MDBW16
Affinity filters
Prevent multiple RS members on the same host:
"affinity:replset!=rs1”
swarm-node-1 swarm-node-3swarm-node-2
Affinity filters for container distribution
#MDBW16
Road to container success
Deploying containers to the right node is not enough…
Next step: Resource control on each swarm cluster node using cgroups
Maritime New Zealand
#MDBW16
Resource control with cgroups and Docker
Simple parameters to add to docker run or compose:
--cpu-shares
--cpuset-cpus
--memory
--blkio-weight
--net
#MDBW16
MongoDB Memory usage in 3.2
with WiredTiger
MongoDB Memory:
mongod process: connections, aggregations, mapReduce, etc
WiredTiger cache: (0.6 x total memory) – 1 GB
Total = mem(mongod) + mem(WiredTiger cache)
WiredTiger cache
mongod
mongod memory
#MDBW16
cgroup!
memory_limit!
Process memory with containers and cgroups
WiredTiger cache
mongod
mongod memory
total memory (seen from mongod process)!
Inside the container
•  Can see total memory and not
memory limit
WiredTiger cache:
•  memory_limit *0.6
#MDBW16
cgroups: Memory and CPU limits
mongod! mongod! mongod! mongod!
MEM = (TOTAL_MEM - OS_MEM) / NUM_MONGOD
WiredTiger cache = (MEM * 0.6) CPUSET= 0, 1, …, MAX_CPU_CORES
mongod!
mongod!
mongod!
mongod!
#MDBW16
MongoDB on Docker + cgroups: Memory
WiredTiger cache:
60% of the container memory limit (for each mongod)
Compose: mem_limit!
Docker Engine: --memory!
WiredTiger cache!
!
!
!
!
!
!
mongod memory!
WiredTiger cache!
!
!
!
!
!
mongod memory!
WiredTiger cache!
!
!
!
!
!
!
mongod memory!
WiredTiger cache!
!
!
!
!
!
!
mongod memory!
OS Memory!
#MDBW16
MongoDB on Docker + cgroups: CPU
mongod (and mongos) mapped to 1+ core
Compose: cpuset!
Docker Engine: --cpuset-cpus!
mongod!
rs1a!
mongod!
rs1a!
mongod!
rs2b!
mongod!
rs2b!
core0! core1! core2! core3!
OS! OS!
mongod
cfgsrv
-c!
mongos!
core4! core5! core6! core7!
--cpuset-mems (NUMA)!
#MDBW16
Understanding resource usage:
•  docker top rs1a!
•  docker stats rs1a!
Container stats available via Docker remote API:
GET /containers/(id)/stats
Also available from docker-py:
http://docker-py.readthedocs.org/en/latest/api/#stats
Resource usage with Docker
#MDBW16
Resource usage with Docker
Multiple statistics for each container:
Memory limit and usage, CPU (per core level), Network, Disk
Useful to combine with MongoDB metrics (like db.serverStatus())
#MDBW16
Creating a Swarm cluster on AWS to deploy MongoDB
#MDBW16
Creating a Swarm cluster on AWS to deploy MongoDB
DEMO!
Configure docker-machine
with ec2 driver (AWS)
Deploy discovery service
for Swarm Master
Deploy AWS instances for:
•  Swarm master
•  Swarm worker nodes
Connect to the Swarm
master
Define compose file for
deployment
Define Swarm filters and
constraints and cgroup
limits
Deploy the environment
with a single command
using the compose file
Configure our MongoDB
sharded cluster using
Cloud Manager API
#MDBW16
What our dockerized sharded cluster looks like…
rs1a!
rs1c!rs1b! rs2b!
rs2a!
rs2c! rs3b!
rs3a!
rs3c!
mongos!
cfgsvr
-a!
cfgsvr
-b!
cfgsvr
-c!
dockerC1! dockerC2! dockerC3!
PRIMARY!
SECONDARY!
MONGOS!
Summary
#MDBW16
Advantages of using MongoDB with Docker
Speed: testing and deploying cluster patterns easily
Build once, deploy everywhere
Control: Resource control and utilization
Key to success with containers
Agility: Microservices architectures
Making change less expensive
Flexibility: Multi vendor cloud opportunities
AWS, Azure, Google, IBM, CloudFoundry
P	
S	
S
#MDBW16
How successful customers use MongoDB with Docker
•  Case Studies @	hGps://www.mongodb.com/blog	
•  Whitepaper:
“Enabling Microservices – Containers & Orchestration Explained”
https://www.mongodb.com/collateral/microservices-containers-and-orchestration-explained
#MDBW16
Now it’s YOUR turn
Share with us your use case of MongoDB & Docker:
http://bit.do/DockerMongoDB
@marcobonezzi
You can actually try this at home:
https://github.com/sisteming/mongo-swarm
Thank You!
Marco Bonezzi
marco@mongodb.com
@marcobonezzi

More Related Content

What's hot

MongoDB and Windows Azure
MongoDB and Windows AzureMongoDB and Windows Azure
MongoDB and Windows Azure
Doug Mahugh
 
Introduction to Docker at Glidewell Laboratories in Orange County
Introduction to Docker at Glidewell Laboratories in Orange CountyIntroduction to Docker at Glidewell Laboratories in Orange County
Introduction to Docker at Glidewell Laboratories in Orange County
Jérôme Petazzoni
 
Introduction to Docker (and a bit more) at LSPE meetup Sunnyvale
Introduction to Docker (and a bit more) at LSPE meetup SunnyvaleIntroduction to Docker (and a bit more) at LSPE meetup Sunnyvale
Introduction to Docker (and a bit more) at LSPE meetup Sunnyvale
Jérôme Petazzoni
 
High Availability != High-cost
High Availability != High-costHigh Availability != High-cost
High Availability != High-cost
normanmaurer
 
Rise of node(Part I)
Rise of node(Part I)Rise of node(Part I)
Rise of node(Part I)
Goddy Zhao
 
MySQL cluster workshop
MySQL cluster workshopMySQL cluster workshop
MySQL cluster workshop
郁萍 王
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.js
Fred Chien
 
Node
NodeNode
Ceph Internals
Ceph InternalsCeph Internals
Ceph Internals
Victor Santos
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
Bhargav Anadkat
 
Linux Virtualization
Linux VirtualizationLinux Virtualization
Linux Virtualization
OpenVZ
 
Saint2012 mod process security
Saint2012 mod process securitySaint2012 mod process security
Saint2012 mod process security
Ryosuke MATSUMOTO
 
LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?
Jérôme Petazzoni
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
Why we (Day) open source most of our code
Why we (Day) open source most of our codeWhy we (Day) open source most of our code
Why we (Day) open source most of our code
Bertrand Delacretaz
 
MongoDB and Windows Azure
MongoDB and Windows AzureMongoDB and Windows Azure
MongoDB and Windows Azure
MongoDB
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
Justyna Ilczuk
 
Performance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networksPerformance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networks
Marian Marinov
 
Open Innovation means Open Source
Open Innovation means Open SourceOpen Innovation means Open Source
Open Innovation means Open Source
Bertrand Delacretaz
 
How we dockerized a startup
How we dockerized a startupHow we dockerized a startup
How we dockerized a startup
Jonathan Martin
 

What's hot (20)

MongoDB and Windows Azure
MongoDB and Windows AzureMongoDB and Windows Azure
MongoDB and Windows Azure
 
Introduction to Docker at Glidewell Laboratories in Orange County
Introduction to Docker at Glidewell Laboratories in Orange CountyIntroduction to Docker at Glidewell Laboratories in Orange County
Introduction to Docker at Glidewell Laboratories in Orange County
 
Introduction to Docker (and a bit more) at LSPE meetup Sunnyvale
Introduction to Docker (and a bit more) at LSPE meetup SunnyvaleIntroduction to Docker (and a bit more) at LSPE meetup Sunnyvale
Introduction to Docker (and a bit more) at LSPE meetup Sunnyvale
 
High Availability != High-cost
High Availability != High-costHigh Availability != High-cost
High Availability != High-cost
 
Rise of node(Part I)
Rise of node(Part I)Rise of node(Part I)
Rise of node(Part I)
 
MySQL cluster workshop
MySQL cluster workshopMySQL cluster workshop
MySQL cluster workshop
 
Let s Enjoy Node.js
Let s Enjoy Node.jsLet s Enjoy Node.js
Let s Enjoy Node.js
 
Node
NodeNode
Node
 
Ceph Internals
Ceph InternalsCeph Internals
Ceph Internals
 
Basic Concept of Node.js & NPM
Basic Concept of Node.js & NPMBasic Concept of Node.js & NPM
Basic Concept of Node.js & NPM
 
Linux Virtualization
Linux VirtualizationLinux Virtualization
Linux Virtualization
 
Saint2012 mod process security
Saint2012 mod process securitySaint2012 mod process security
Saint2012 mod process security
 
LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?LXC, Docker, security: is it safe to run applications in Linux Containers?
LXC, Docker, security: is it safe to run applications in Linux Containers?
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los AngelesDocker 0.11 at MaxCDN meetup in Los Angeles
Docker 0.11 at MaxCDN meetup in Los Angeles
 
Why we (Day) open source most of our code
Why we (Day) open source most of our codeWhy we (Day) open source most of our code
Why we (Day) open source most of our code
 
MongoDB and Windows Azure
MongoDB and Windows AzureMongoDB and Windows Azure
MongoDB and Windows Azure
 
Docker in everyday development
Docker in everyday developmentDocker in everyday development
Docker in everyday development
 
Performance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networksPerformance comparison of Distributed File Systems on 1Gbit networks
Performance comparison of Distributed File Systems on 1Gbit networks
 
Open Innovation means Open Source
Open Innovation means Open SourceOpen Innovation means Open Source
Open Innovation means Open Source
 
How we dockerized a startup
How we dockerized a startupHow we dockerized a startup
How we dockerized a startup
 

Similar to Scaling MongoDB with Docker and cgroups

MongoDB Europe 2016 - Powering Microservices with Docker, Kubernetes, and Kafka
MongoDB Europe 2016 - Powering Microservices with Docker, Kubernetes, and KafkaMongoDB Europe 2016 - Powering Microservices with Docker, Kubernetes, and Kafka
MongoDB Europe 2016 - Powering Microservices with Docker, Kubernetes, and Kafka
MongoDB
 
Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...
Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...
Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...
Andrew Morgan
 
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDBPowering Microservices with Docker, Kubernetes, Kafka, and MongoDB
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
MongoDB
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developers
Suraj Deshmukh
 
Deploy Nodejs on Docker
Deploy Nodejs on DockerDeploy Nodejs on Docker
Deploy Nodejs on Docker
Will Button
 
Docker 101
Docker 101Docker 101
Docker 101
Lâm Đào
 
MongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseMongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL Database
FITC
 
MongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big ComputeMongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big Compute
MongoDB
 
Webinar: Enabling Microservices with Containers, Orchestration, and MongoDB
Webinar: Enabling Microservices with Containers, Orchestration, and MongoDBWebinar: Enabling Microservices with Containers, Orchestration, and MongoDB
Webinar: Enabling Microservices with Containers, Orchestration, and MongoDB
MongoDB
 
Jumpstart: Your Introduction To MongoDB
Jumpstart: Your Introduction To MongoDBJumpstart: Your Introduction To MongoDB
Jumpstart: Your Introduction To MongoDB
MongoDB
 
MongoDB .local Bengaluru 2019: Using MongoDB Services in Kubernetes: Any Plat...
MongoDB .local Bengaluru 2019: Using MongoDB Services in Kubernetes: Any Plat...MongoDB .local Bengaluru 2019: Using MongoDB Services in Kubernetes: Any Plat...
MongoDB .local Bengaluru 2019: Using MongoDB Services in Kubernetes: Any Plat...
MongoDB
 
Let's Containerize New York with Docker!
Let's Containerize New York with Docker!Let's Containerize New York with Docker!
Let's Containerize New York with Docker!
Jérôme Petazzoni
 
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
MongoDB
 
Jumpstart: Your Introduction to MongoDB
Jumpstart: Your Introduction to MongoDBJumpstart: Your Introduction to MongoDB
Jumpstart: Your Introduction to MongoDB
MongoDB
 
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UKStorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
StorageOS
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
Hao Fan
 
Accelerate your development with Docker
Accelerate your development with DockerAccelerate your development with Docker
Accelerate your development with Docker
Andrey Hristov
 
Accelerate your software development with Docker
Accelerate your software development with DockerAccelerate your software development with Docker
Accelerate your software development with Docker
Andrey Hristov
 
Docker in real life
Docker in real lifeDocker in real life
Docker in real life
Nguyen Van Vuong
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
Michael Lange
 

Similar to Scaling MongoDB with Docker and cgroups (20)

MongoDB Europe 2016 - Powering Microservices with Docker, Kubernetes, and Kafka
MongoDB Europe 2016 - Powering Microservices with Docker, Kubernetes, and KafkaMongoDB Europe 2016 - Powering Microservices with Docker, Kubernetes, and Kafka
MongoDB Europe 2016 - Powering Microservices with Docker, Kubernetes, and Kafka
 
Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...
Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...
Powering Microservices with MongoDB, Docker, Kubernetes & Kafka – MongoDB Eur...
 
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDBPowering Microservices with Docker, Kubernetes, Kafka, and MongoDB
Powering Microservices with Docker, Kubernetes, Kafka, and MongoDB
 
Making kubernetes simple for developers
Making kubernetes simple for developersMaking kubernetes simple for developers
Making kubernetes simple for developers
 
Deploy Nodejs on Docker
Deploy Nodejs on DockerDeploy Nodejs on Docker
Deploy Nodejs on Docker
 
Docker 101
Docker 101Docker 101
Docker 101
 
MongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL DatabaseMongoDB: Advantages of an Open Source NoSQL Database
MongoDB: Advantages of an Open Source NoSQL Database
 
MongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big ComputeMongoDB Europe 2016 - Big Data meets Big Compute
MongoDB Europe 2016 - Big Data meets Big Compute
 
Webinar: Enabling Microservices with Containers, Orchestration, and MongoDB
Webinar: Enabling Microservices with Containers, Orchestration, and MongoDBWebinar: Enabling Microservices with Containers, Orchestration, and MongoDB
Webinar: Enabling Microservices with Containers, Orchestration, and MongoDB
 
Jumpstart: Your Introduction To MongoDB
Jumpstart: Your Introduction To MongoDBJumpstart: Your Introduction To MongoDB
Jumpstart: Your Introduction To MongoDB
 
MongoDB .local Bengaluru 2019: Using MongoDB Services in Kubernetes: Any Plat...
MongoDB .local Bengaluru 2019: Using MongoDB Services in Kubernetes: Any Plat...MongoDB .local Bengaluru 2019: Using MongoDB Services in Kubernetes: Any Plat...
MongoDB .local Bengaluru 2019: Using MongoDB Services in Kubernetes: Any Plat...
 
Let's Containerize New York with Docker!
Let's Containerize New York with Docker!Let's Containerize New York with Docker!
Let's Containerize New York with Docker!
 
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
Creating Highly-Available MongoDB Microservices with Docker Containers and Ku...
 
Jumpstart: Your Introduction to MongoDB
Jumpstart: Your Introduction to MongoDBJumpstart: Your Introduction to MongoDB
Jumpstart: Your Introduction to MongoDB
 
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UKStorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
StorageOS, Storage for Containers Shouldn't Be Annoying at Container Camp UK
 
Docker Introduction
Docker IntroductionDocker Introduction
Docker Introduction
 
Accelerate your development with Docker
Accelerate your development with DockerAccelerate your development with Docker
Accelerate your development with Docker
 
Accelerate your software development with Docker
Accelerate your software development with DockerAccelerate your software development with Docker
Accelerate your software development with Docker
 
Docker in real life
Docker in real lifeDocker in real life
Docker in real life
 
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other ThingsI Just Want to Run My Code: Waypoint, Nomad, and Other Things
I Just Want to Run My Code: Waypoint, Nomad, and Other Things
 

Recently uploaded

Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
SakkaravarthiShanmug
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
LAXMAREDDY22
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...
IJECEIAES
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
VANDANAMOHANGOUDA
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
Prakhyath Rai
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
abbyasa1014
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
gowrishankartb2005
 
integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
gaafergoudaay7aga
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
riddhimaagrawal986
 
CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
PKavitha10
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 

Recently uploaded (20)

Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
cnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classicationcnn.pptx Convolutional neural network used for image classication
cnn.pptx Convolutional neural network used for image classication
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 
BRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdfBRAIN TUMOR DETECTION for seminar ppt.pdf
BRAIN TUMOR DETECTION for seminar ppt.pdf
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...An improved modulation technique suitable for a three level flying capacitor ...
An improved modulation technique suitable for a three level flying capacitor ...
 
ITSM Integration with MuleSoft.pptx
ITSM  Integration with MuleSoft.pptxITSM  Integration with MuleSoft.pptx
ITSM Integration with MuleSoft.pptx
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
 
Engineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdfEngineering Drawings Lecture Detail Drawings 2014.pdf
Engineering Drawings Lecture Detail Drawings 2014.pdf
 
Material for memory and display system h
Material for memory and display system hMaterial for memory and display system h
Material for memory and display system h
 
integral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdfintegral complex analysis chapter 06 .pdf
integral complex analysis chapter 06 .pdf
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
People as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimalaPeople as resource Grade IX.pdf minimala
People as resource Grade IX.pdf minimala
 
CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1CEC 352 - SATELLITE COMMUNICATION UNIT 1
CEC 352 - SATELLITE COMMUNICATION UNIT 1
 
Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 

Scaling MongoDB with Docker and cgroups

  • 1. Scaling MongoDB with Docker and cgroups Marco Bonezzi TechnicalServicesEngineer,MongoDB marco@mongodb.com @marcobonezzi
  • 2. #MDBW16 About the speaker I am Marco Bonezzi, TSE at MongoDB TSE = helping customers with a variety of issues Based in Dublin, Ireland Experience in distributed systems, high availability:
  • 3. #MDBW16 How many of you have ever... 1.  … manually deployed a MongoDB replica sets or sharded clusters? 2.  ... had issues with resource allocation? 3.  ... used Docker? 4.  … used MongoDB running on Docker?
  • 4. #MDBW16 We know how it feels… Different architectures in Development and Production Co-located MongoDB processes Production != docker run mongodb
  • 5. #MDBW16 What are the pain points? Deployment Complex architectures and deployment patterns Resource Contention Multiple instances competing for resources MongoDB & Docker Combining both: network configuration, container location, other
  • 6. #MDBW16 How to solve this? Deployment Using predefined cluster patterns Replicating environments Resource Control Setting limits to key resources MongoDB & Docker Create once, deploy everywhere Deploy patterns, not processes Orchestration Resource Management Automate for scaling
  • 7. #MDBW16 About this talk Patterns for successful deployments Difference between success and failure Orchestrating MongoDB with Docker MongoDB cluster on AWS with containers Patterns with Swarm and Compose Managing container resources with cgroups Benefits of cgroups in a MongoDB cluster P S S
  • 8. #MDBW16 Redundancy and fault tolerance Deploy an odd number of voting members Members ó Majority required ó Fault tolerance High availability and resource colocation Single member of a replica set / server Shards as Replica Set Ideally: primary / secondary / secondary Deployment patterns: Replica Set and Sharded Clusters Server 3Server 2Server 1 mongos Primary Primary RS1 SecondarySecondary Secondary RS2 Secondary RS3 Secondary RS1 Primary RS2 Secondary RS3 Secondary RS1 Secondary RS2 Primary RS3 mongos mongos cfgsvr1 cfgsvr2 cfgsvr3
  • 9. #MDBW16 Docker •  Noun: a person employed in a port to load and unload ships (from “what is docker” on Google) Containers: Isolated process in userspace Application + dependencies Shared kernel and libraries Can run on any infrastructure (or cloud) www.docker.com
  • 10. #MDBW16 44% of orgs adopting microservices Why use Docker? 41% want application portability 13x improvement in release frequency 62% MTTR on software issues 60% Using Docker to migrate to cloud Reason to run containers: SPEED Microservices architectures Efficiency Cloud (The Docker Survey, 2016)
  • 11. #MDBW16 Good news: Docker can help with this! Orchestration Coordinate MongoDB containers to deploy a recommended deployment pattern Resource Control Sizing each instance (and each cluster) to avoid resource contention issues
  • 12. #MDBW16 Orchestrating MongoDB with Docker How can we use Docker for MongoDB deployments? How can we deploy these patterns using Docker containers? Why should we use Docker? Our recipe:
  • 13. #MDBW16 Docker ecosystem Provisioning and managing your Dockerized hosts Native clustering: turns a pool of Docker hosts into a single, virtual Docker host. Define a multi-container application with all of its dependencies in a single file S
  • 14. #MDBW16 Why Docker Swarm? 5x faster than Kubernetes to spin up a new container 7x faster than Kubernetes to list all running containers Evaluating Container Platforms at Scale 1000 EC2 instances in a cluster What is their performance at scale? Can they operate at scale? What does it take to support them at scale? https://medium.com/on-docker/evaluating-container-platforms-at-scale-5e7b44d93f2c#.k2fxds8c2 hGps://www.docker.com/survey-2016
  • 15. #MDBW16 swarm-node-2 swarm-node-3swarm-node-1 Swarm multi-host networking How each mongod process connects to other processes outside of the host? •  Swarm overlay container-to-container network •  Using the hostname defined in the Compose file
  • 16. #MDBW16 Swarm filters to build our patterns Constraint filters Mark each mongod container with a label: “role=mongod” “replset=rs1”
  • 17. #MDBW16 Affinity filters Prevent multiple RS members on the same host: "affinity:replset!=rs1” swarm-node-1 swarm-node-3swarm-node-2 Affinity filters for container distribution
  • 18. #MDBW16 Road to container success Deploying containers to the right node is not enough… Next step: Resource control on each swarm cluster node using cgroups Maritime New Zealand
  • 19. #MDBW16 Resource control with cgroups and Docker Simple parameters to add to docker run or compose: --cpu-shares --cpuset-cpus --memory --blkio-weight --net
  • 20. #MDBW16 MongoDB Memory usage in 3.2 with WiredTiger MongoDB Memory: mongod process: connections, aggregations, mapReduce, etc WiredTiger cache: (0.6 x total memory) – 1 GB Total = mem(mongod) + mem(WiredTiger cache) WiredTiger cache mongod mongod memory
  • 21. #MDBW16 cgroup! memory_limit! Process memory with containers and cgroups WiredTiger cache mongod mongod memory total memory (seen from mongod process)! Inside the container •  Can see total memory and not memory limit WiredTiger cache: •  memory_limit *0.6
  • 22. #MDBW16 cgroups: Memory and CPU limits mongod! mongod! mongod! mongod! MEM = (TOTAL_MEM - OS_MEM) / NUM_MONGOD WiredTiger cache = (MEM * 0.6) CPUSET= 0, 1, …, MAX_CPU_CORES mongod! mongod! mongod! mongod!
  • 23. #MDBW16 MongoDB on Docker + cgroups: Memory WiredTiger cache: 60% of the container memory limit (for each mongod) Compose: mem_limit! Docker Engine: --memory! WiredTiger cache! ! ! ! ! ! ! mongod memory! WiredTiger cache! ! ! ! ! ! mongod memory! WiredTiger cache! ! ! ! ! ! ! mongod memory! WiredTiger cache! ! ! ! ! ! ! mongod memory! OS Memory!
  • 24. #MDBW16 MongoDB on Docker + cgroups: CPU mongod (and mongos) mapped to 1+ core Compose: cpuset! Docker Engine: --cpuset-cpus! mongod! rs1a! mongod! rs1a! mongod! rs2b! mongod! rs2b! core0! core1! core2! core3! OS! OS! mongod cfgsrv -c! mongos! core4! core5! core6! core7! --cpuset-mems (NUMA)!
  • 25. #MDBW16 Understanding resource usage: •  docker top rs1a! •  docker stats rs1a! Container stats available via Docker remote API: GET /containers/(id)/stats Also available from docker-py: http://docker-py.readthedocs.org/en/latest/api/#stats Resource usage with Docker
  • 26. #MDBW16 Resource usage with Docker Multiple statistics for each container: Memory limit and usage, CPU (per core level), Network, Disk Useful to combine with MongoDB metrics (like db.serverStatus())
  • 27. #MDBW16 Creating a Swarm cluster on AWS to deploy MongoDB
  • 28. #MDBW16 Creating a Swarm cluster on AWS to deploy MongoDB DEMO! Configure docker-machine with ec2 driver (AWS) Deploy discovery service for Swarm Master Deploy AWS instances for: •  Swarm master •  Swarm worker nodes Connect to the Swarm master Define compose file for deployment Define Swarm filters and constraints and cgroup limits Deploy the environment with a single command using the compose file Configure our MongoDB sharded cluster using Cloud Manager API
  • 29. #MDBW16 What our dockerized sharded cluster looks like… rs1a! rs1c!rs1b! rs2b! rs2a! rs2c! rs3b! rs3a! rs3c! mongos! cfgsvr -a! cfgsvr -b! cfgsvr -c! dockerC1! dockerC2! dockerC3! PRIMARY! SECONDARY! MONGOS!
  • 31. #MDBW16 Advantages of using MongoDB with Docker Speed: testing and deploying cluster patterns easily Build once, deploy everywhere Control: Resource control and utilization Key to success with containers Agility: Microservices architectures Making change less expensive Flexibility: Multi vendor cloud opportunities AWS, Azure, Google, IBM, CloudFoundry P S S
  • 32. #MDBW16 How successful customers use MongoDB with Docker •  Case Studies @ hGps://www.mongodb.com/blog •  Whitepaper: “Enabling Microservices – Containers & Orchestration Explained” https://www.mongodb.com/collateral/microservices-containers-and-orchestration-explained
  • 33. #MDBW16 Now it’s YOUR turn Share with us your use case of MongoDB & Docker: http://bit.do/DockerMongoDB @marcobonezzi You can actually try this at home: https://github.com/sisteming/mongo-swarm