SlideShare a Scribd company logo
Cassandra and Docker
Two buzzwords or a match made in heaven?
instaclustr.com
@Instaclustr
Who am I and what do I do?
• Ben Bromhead
• Co-founder and CTO of Instaclustr -> www.instaclustr.com
<sales>
• Instaclustr provides Cassandra-as-a-Service in the cloud.
• Currently in AWS, Azure and Google Cloud in private beta with more to come.
• We currently manage 50+ nodes for various customers, who do various things with
it.
</sales>
Objectives
• A quick intro on docker.
• Why docker matters and how it works.
• Working with Cassandra and docker.
• Running C* in a constrained env w/ docker
The Challenge
Static website
Web frontend
DB
Queue
Background workers
API endpoint
nginx 1.5 + modsecurity + openssl + bootstrap 2
Java + Cassandra + Spark
Ruby + Rails + sass + Unicorn
Redis + redis-sentinel
Python 3.0 + celery + pyredis + libcurl + ffmpeg + libopencv + nodejs +
phantomjs
Python 2.7 + Flask + pyredis + celery + psycopg + postgresql-client
DevelopmentVM
QA server
Public Cloud
Disaster recovery
Contributor’s laptop
Production Servers
Mul$plicity*of*Stacks*
Mul$plicity*of*
hardware*
environments*
Production Cluster
Customer Data Center
Do*services*and*apps*
interact*
appropriately?*
Can*I*migrate*
smoothly*and*
quickly?*
Static website
Web frontend
Background workers
DB
Analytics
Queue
Developmen
t VM
QA Server
Single Prod
Server
Onsite
Cluster
Public Cloud
Contributor’
s laptop
Customer
Servers
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Dependency madness
Pre 1960’s transportMul$plicity*of*Goods*
Mul$pilicity*of*
methods*for*
transpor$ng/storing*
Do*I*worry*about*
how*goods*interact*
(e.g.*coffee*beans*
next*to*spices)*
Can*I*transport*quickly*
and*smoothly*
(e.g.*from*boat*to*
train*to*truck)*
Also a dependency mess
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
? ? ? ? ? ? ?
Solution: Intermodal Shipping containers
Mul$plicity*of*Goods*
Mul$plicity*of*
methods*for*
transpor$ng/storing*
Do*I*worry*about*
how*goods*interact*
(e.g.*coffee*beans*
next*to*spices)*
Can*I*transport*
quickly*and*smoothly*
(e.g.*from*boat*to*
train*to*truck)*
…in between, can be loaded and
unloaded, stacked, transported
efficiently over long distances,
and transferred from one mode
of transport to another!
A standard container that is
loaded with virtually any
goods, and stays sealed until
it reaches final delivery.!
Docker, shipping containers for code
Static website Web frontendUser DB Queue Analytics DB
Development
VM
QA server Public Cloud Contributor’s
laptop
Mul$plicity*of*Stacks*
Mul$plicity*of*
hardware*
environments*
Production Cluster
Customer Data
Center
Do*services*and*apps*
interact*
appropriately?*
Can*I*migrate*
smoothly*and*quickly*
…that can be manipulated using
standard operations and run
consistently on virtually any
hardware platform !
An engine that enables any
payload to be encapsulated
as a lightweight, portable,
self-sufficient container…!
Solves the deployment dependency matrix
Static website
Web frontend
Background workers
User DB
Analytics DB
Queue
Developmen
t VM
QA Server
Single Prod
Server
Onsite
Cluster
Public Cloud
Contributor’
s laptop
Customer
Servers
Why docker matters
• Finally Developers have a solution to build once and deploy
anywhere
• Finally Ops/Admin has a solution to configure anywhere
• Finally DevOps is easy
• Dev == Test == Staging == Production
• Move with speed
Docker, how it works.
• Runs anywhere (Linux kernel 2.6.32+)
• Uses lightweight VMs:
• Own process space (namespace)
• Process isolation and resource control (cgroups)
• Own network adapter
• Own filesystem (chroot)
• Linux Analog to Solaris Zones, *BSD jails
Docker, how it works.
• Difference between a container and a VM
Virtual Machine Container
Docker, how it works.
• What about the packaging component?
• Uses Union filesystem to create a git like workflow around your deployed code:
!
!
Docker!
Container!
Image!
Registry!
Push%
!
!
!
!
Bins/!
Libs!
!
!
!
!
App!
A!
App!Δ!!
!
!
!
!
Bins/!
Docker'Engine' Docker'Engine'
Update'
Host'is'now'running'A’’'
'
App'Δ''
'
'
'
'
Bins/'
'
'
'
'
Bins/'
Libs'
'
'
'
'
App'
A'
'
'
'
'
Bins/'
'
'
'
'
Bins/'
Libs'
'
'
'
'
App'
A’’'
Host'running'A'wants'to'upgrade'to'A’’.'
Requests'update.'Gets'only'diffs'
'
Docker is it production ready?
Cassandra and Docker
• So how do we get on board the hype train? Without killing
performance or stability?
• Build Cassandra in a docker container, run it, then test.
• Run in dev to get comfortable with it.
• Talk to others who use it in production
• https://github.com/docker/docker/issues - You will spend a lot of
time here
Docker + Networking
• 1st attempt, throughput dropped in half!
• Writes sucked, streaming sucked, what was going on?
• Quick check with iperf showed a 50% hit in throughput
• Docker uses Linux Ethernet Bridges for basic software defined
routing. This will hose your network throughput.
• Use the host network stack instead (—net=host), only saw a ~10%
hit on network performance
Docker + Networking
• Docker uses Linux Ethernet Bridges for basic software defined
routing. This will hose your network throughput.
• Use the host network stack instead (—net=host), only saw a ~10%
hit on network performance
• Also solves NAT issues in an AWS like networking environment.
Docker + Filesystem
• Don’t want to throw it out when you upgrade/stop container.
• Use volume mount folders to the underlying host!
Docker + Filesystem
• The filesystems (AUFS, BTRFS etc) that bring great benefits to
Dockers workflow around building and snapshoting containers are
not very good for databases.
• UnionFS (AUFS) is terrible for writing lots of big files.
• BTRFS is a pain to use from an ops point of view.
• Hooray volume mounts use the underlying filesystem.
Docker + Process Capabilities
• Mlockall permission denied? A process needs CAP_IPC_LOCK &
RLIMIT_MEMLOCK in order to perform this operation. By default
docker doesn't assign this to a running container…
• Can’t use native memory. Cassandra becomes slooow.
• Can use --privileged and be done with it. Kind of lazy though
• Use --cap-add instead
Docker + SIGTERM propagation
• When stopping the process docker will send a SIGTERM.
• PID 1 does not have default signal handlers!
• Bad if you use a bash script to launch Cassandra
Images shameless copied from https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/
Docker + SIGTERM propagation
• Java to the rescue!
• Make sure you run the cassandra bash script with -f (foreground)
• exec causes the JVM to replace the bash process… making the
world a happier place
Docker + SIGTERM propagation
• Tools like OpsCenter Server will have trouble with this.
• Can be fixed using a wacky combination of trap and wait stanzas in
your OpsCenter Server script (see http://veithen.github.io/
2014/11/16/sigterm-propagation.html)
• But now you have a bash script that duplicates init/systemd/
supervisord
• The debate rages on…
Docker + CoreOS
• Docker + fav OS + CM?, CoreOS + etcd, Swarm + Machine, Deis
etc
• We chose CoreOS (Appeared to be sane, etcd is cool, systemd if
you are into that kind of thing)
Docker + CoreOS
• Disable automatic updates + restarts (seriously do this)
• Fix logging, otherwise you will log to 3 locations (/var/log/
cassandra, journalctl and dockers json based log
• JVM will exit with error 143 (128 + 15 for SIGTERM). Need to ignore
that in your systemd service definition.
Docker + Dev Env
• Docker relies on Linux kernel capabilites… so no native docker in
OS X
• We use OSX for dev, so we run vagrant and the CoreOS vagrant file
https://github.com/coreos/coreos-vagrant
• Look at https://github.com/tobert/cassandra-docker for something
more off the shelf
Docker + C* + Dev Env
• How do I run lots of C* instances on a VM or my dev laptop without
it falling over?
• Make it run as slowly, but as stable as possible!
• This is actually a great learning exercise as you discover a lot about
how Cassandra works under the hood.
Docker + C* + Dev Env
• Set Memory to be super low, edit your cassandra-env.sh:
MAX_HEAP_SIZE="128M"	
  
HEAP_NEWSIZE="24M"
Docker + C* + Dev Env
• Tune compaction to have free reign and to smash the disk
concurrent_compactors:	
  1	
  
in_memory_compaction_limit_in_mb:	
  2	
  
compaction_throughput_mb_per_sec:	
  0
Docker + C* + Dev Env
• Let’s use HSHA thrift server as it reduces the memory per thread
used.
rpc_server_type:	
  hsha
Docker + C* + Dev Env
• The HSHA server also lets us limit the number of threads serving in
flight requests, but still have a large number of clients connected.
concurrent_reads:	
  4	
  
concurrent_writes:	
  4	
  
rpc_min_threads:	
  2	
  
rpc_max_threads:	
  2
• You can play with these to get the right numbers based on how your
clients connect, but keep them low.
Docker + C* + Dev Env
• This is Dev! Caches have no power here!
key_cache_size_in_mb:	
  0	
  
reduce_cache_sizes_at:	
  0	
  
reduce_cache_capacity_to:	
  0
Docker + C* + Dev Env
• How well does this work?!?!
• Will survive running the insane workload in the c* 2.1 new stresstest
tool.
• We run this on AWS t1.micro instances
• Sign up at https://www.instaclustr.com and give our new Developer
nodes a spin!
Go forth and conquer!
Questions?

More Related Content

What's hot (20)

PPTX
Openstack Magnum: Container-as-a-Service
Chhavi Agarwal
 
PDF
Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...
Claus Ibsen
 
PPTX
A brief study on Kubernetes and its components
Ramit Surana
 
PDF
Kubernetes - A Comprehensive Overview
Bob Killen
 
PDF
Glusterfs 소개 v1.0_난공불락세미나
sprdd
 
PDF
DevOps Open House III - Kubernetes using YAML
Agile Testing Alliance
 
PPTX
Azure subscription management with EA and CSP
Daichi Isami
 
PDF
Tadx - Présentation Conteneurisation
TADx
 
PPTX
[넥슨] kubernetes 소개 (2018)
용호 최
 
PDF
Intro to containerization
Balint Pato
 
PPTX
DevOps at FSOFT as BOI | Nguyễn Hoài Nam, Vũ Xuân Lộc
Vietnam Open Infrastructure User Group
 
PDF
Tracing Micro Services with OpenTracing
Hemant Kumar
 
PDF
스타트업 나홀로 데이터 엔지니어: 데이터 분석 환경 구축기 - 천지은 (Tappytoon) :: AWS Community Day Onlin...
AWSKRUG - AWS한국사용자모임
 
PDF
Kubernetes dealing with storage and persistence
Janakiram MSV
 
PDF
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Henning Jacobs
 
PDF
A la découverte de kubernetes
Julien Maitrehenry
 
PDF
Kubernetes design principles, patterns and ecosystem
Sreenivas Makam
 
PPTX
Everything You Need To Know About Persistent Storage in Kubernetes
The {code} Team
 
PPTX
Introduction To AWS & AWS Lambda
An Nguyen
 
Openstack Magnum: Container-as-a-Service
Chhavi Agarwal
 
Red Hat Nordics 2020 - Apache Camel 3 the next generation of enterprise integ...
Claus Ibsen
 
A brief study on Kubernetes and its components
Ramit Surana
 
Kubernetes - A Comprehensive Overview
Bob Killen
 
Glusterfs 소개 v1.0_난공불락세미나
sprdd
 
DevOps Open House III - Kubernetes using YAML
Agile Testing Alliance
 
Azure subscription management with EA and CSP
Daichi Isami
 
Tadx - Présentation Conteneurisation
TADx
 
[넥슨] kubernetes 소개 (2018)
용호 최
 
Intro to containerization
Balint Pato
 
DevOps at FSOFT as BOI | Nguyễn Hoài Nam, Vũ Xuân Lộc
Vietnam Open Infrastructure User Group
 
Tracing Micro Services with OpenTracing
Hemant Kumar
 
스타트업 나홀로 데이터 엔지니어: 데이터 분석 환경 구축기 - 천지은 (Tappytoon) :: AWS Community Day Onlin...
AWSKRUG - AWS한국사용자모임
 
Kubernetes dealing with storage and persistence
Janakiram MSV
 
Optimizing Kubernetes Resource Requests/Limits for Cost-Efficiency and Latenc...
Henning Jacobs
 
A la découverte de kubernetes
Julien Maitrehenry
 
Kubernetes design principles, patterns and ecosystem
Sreenivas Makam
 
Everything You Need To Know About Persistent Storage in Kubernetes
The {code} Team
 
Introduction To AWS & AWS Lambda
An Nguyen
 

Similar to Cassandra and Docker Lessons Learned (20)

PDF
Cassandra and docker
Ben Bromhead
 
PDF
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
PDF
Docker Introduction + what is new in 0.9
Jérôme Petazzoni
 
PDF
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
Jérôme Petazzoni
 
PDF
Docker and Containers for Development and Deployment — SCALE12X
Jérôme Petazzoni
 
PDF
Docker-v3.pdf
Bruno Cornec
 
PDF
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
TheFamily
 
PDF
Introduction to Docker, December 2014 "Tour de France" Edition
Jérôme Petazzoni
 
PDF
codemotion-docker-2014
Carlo Bonamico
 
PPTX
Dockercon EU 2015
John Fiedler
 
PDF
Accelerate your software development with Docker
Andrey Hristov
 
PPTX
Accelerate your development with Docker
Andrey Hristov
 
PPTX
Cont0519
Samuel Dratwa
 
PDF
JOSA TechTalk: Taking Docker to Production
Jordan Open Source Association
 
PDF
Techtalks: taking docker to production
muayyad alsadi
 
PDF
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.
 
PDF
Docker and-containers-for-development-and-deployment-scale12x
rkr10
 
PDF
Docker Essentials Workshop— Innovation Labs July 2020
CloudHero
 
PDF
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
PDF
Docker, the Future of DevOps
andersjanmyr
 
Cassandra and docker
Ben Bromhead
 
Why everyone is excited about Docker (and you should too...) - Carlo Bonamic...
Codemotion
 
Docker Introduction + what is new in 0.9
Jérôme Petazzoni
 
Docker Introduction, and what's new in 0.9 — Docker Palo Alto at RelateIQ
Jérôme Petazzoni
 
Docker and Containers for Development and Deployment — SCALE12X
Jérôme Petazzoni
 
Docker-v3.pdf
Bruno Cornec
 
Workshop : 45 minutes pour comprendre Docker avec Jérôme Petazzoni
TheFamily
 
Introduction to Docker, December 2014 "Tour de France" Edition
Jérôme Petazzoni
 
codemotion-docker-2014
Carlo Bonamico
 
Dockercon EU 2015
John Fiedler
 
Accelerate your software development with Docker
Andrey Hristov
 
Accelerate your development with Docker
Andrey Hristov
 
Cont0519
Samuel Dratwa
 
JOSA TechTalk: Taking Docker to Production
Jordan Open Source Association
 
Techtalks: taking docker to production
muayyad alsadi
 
Agile Brown Bag - Vagrant & Docker: Introduction
Agile Partner S.A.
 
Docker and-containers-for-development-and-deployment-scale12x
rkr10
 
Docker Essentials Workshop— Innovation Labs July 2020
CloudHero
 
Docker 0.11 at MaxCDN meetup in Los Angeles
Jérôme Petazzoni
 
Docker, the Future of DevOps
andersjanmyr
 
Ad

More from DataStax Academy (20)

PDF
Forrester CXNYC 2017 - Delivering great real-time cx is a true craft
DataStax Academy
 
PPTX
Introduction to DataStax Enterprise Graph Database
DataStax Academy
 
PPTX
Introduction to DataStax Enterprise Advanced Replication with Apache Cassandra
DataStax Academy
 
PPTX
Cassandra on Docker @ Walmart Labs
DataStax Academy
 
PDF
Cassandra 3.0 Data Modeling
DataStax Academy
 
PPTX
Cassandra Adoption on Cisco UCS & Open stack
DataStax Academy
 
PDF
Data Modeling for Apache Cassandra
DataStax Academy
 
PDF
Coursera Cassandra Driver
DataStax Academy
 
PDF
Production Ready Cassandra
DataStax Academy
 
PDF
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
DataStax Academy
 
PPTX
Cassandra @ Sony: The good, the bad, and the ugly part 1
DataStax Academy
 
PPTX
Cassandra @ Sony: The good, the bad, and the ugly part 2
DataStax Academy
 
PDF
Standing Up Your First Cluster
DataStax Academy
 
PDF
Real Time Analytics with Dse
DataStax Academy
 
PDF
Introduction to Data Modeling with Apache Cassandra
DataStax Academy
 
PDF
Cassandra Core Concepts
DataStax Academy
 
PPTX
Enabling Search in your Cassandra Application with DataStax Enterprise
DataStax Academy
 
PPTX
Bad Habits Die Hard
DataStax Academy
 
PDF
Advanced Data Modeling with Apache Cassandra
DataStax Academy
 
PDF
Advanced Cassandra
DataStax Academy
 
Forrester CXNYC 2017 - Delivering great real-time cx is a true craft
DataStax Academy
 
Introduction to DataStax Enterprise Graph Database
DataStax Academy
 
Introduction to DataStax Enterprise Advanced Replication with Apache Cassandra
DataStax Academy
 
Cassandra on Docker @ Walmart Labs
DataStax Academy
 
Cassandra 3.0 Data Modeling
DataStax Academy
 
Cassandra Adoption on Cisco UCS & Open stack
DataStax Academy
 
Data Modeling for Apache Cassandra
DataStax Academy
 
Coursera Cassandra Driver
DataStax Academy
 
Production Ready Cassandra
DataStax Academy
 
Cassandra @ Netflix: Monitoring C* at Scale, Gossip and Tickler & Python
DataStax Academy
 
Cassandra @ Sony: The good, the bad, and the ugly part 1
DataStax Academy
 
Cassandra @ Sony: The good, the bad, and the ugly part 2
DataStax Academy
 
Standing Up Your First Cluster
DataStax Academy
 
Real Time Analytics with Dse
DataStax Academy
 
Introduction to Data Modeling with Apache Cassandra
DataStax Academy
 
Cassandra Core Concepts
DataStax Academy
 
Enabling Search in your Cassandra Application with DataStax Enterprise
DataStax Academy
 
Bad Habits Die Hard
DataStax Academy
 
Advanced Data Modeling with Apache Cassandra
DataStax Academy
 
Advanced Cassandra
DataStax Academy
 
Ad

Recently uploaded (20)

PPTX
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PPTX
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
PPTX
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
PDF
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
PPTX
Distribution reservoir and service storage pptx
dhanashree78
 
PDF
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
PDF
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
PPTX
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
PPTX
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
PPTX
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
PPT
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
PPT
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
PPTX
Knowledge Representation : Semantic Networks
Amity University, Patna
 
PDF
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
PPTX
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
PDF
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
PDF
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
PPTX
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
PDF
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
PPTX
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 
MODULE 03 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Water Resources Engineering (CVE 728)--Slide 4.pptx
mohammedado3
 
澳洲电子毕业证澳大利亚圣母大学水印成绩单UNDA学生证网上可查学历
Taqyea
 
AI TECHNIQUES FOR IDENTIFYING ALTERATIONS IN THE HUMAN GUT MICROBIOME IN MULT...
vidyalalltv1
 
Distribution reservoir and service storage pptx
dhanashree78
 
AN EMPIRICAL STUDY ON THE USAGE OF SOCIAL MEDIA IN GERMAN B2C-ONLINE STORES
ijait
 
Electrical Machines and Their Protection.pdf
Nabajyoti Banik
 
DATA BASE MANAGEMENT AND RELATIONAL DATA
gomathisankariv2
 
Numerical-Solutions-of-Ordinary-Differential-Equations.pptx
SAMUKTHAARM
 
Final Major project a b c d e f g h i j k l m
bharathpsnab
 
New_school_Engineering_presentation_011707.ppt
VinayKumar304579
 
Footbinding.pptmnmkjkjkknmnnjkkkkkkkkkkkkkk
mamadoundiaye42742
 
Knowledge Representation : Semantic Networks
Amity University, Patna
 
20ES1152 Programming for Problem Solving Lab Manual VRSEC.pdf
Ashutosh Satapathy
 
MODULE 05 - CLOUD COMPUTING AND SECURITY.pptx
Alvas Institute of Engineering and technology, Moodabidri
 
Pressure Measurement training for engineers and Technicians
AIESOLUTIONS
 
methodology-driven-mbse-murphy-july-hsv-huntsville6680038572db67488e78ff00003...
henriqueltorres1
 
How Industrial Project Management Differs From Construction.pptx
jamespit799
 
Basic_Concepts_in_Clinical_Biochemistry_2018كيمياء_عملي.pdf
AdelLoin
 
What is Shot Peening | Shot Peening is a Surface Treatment Process
Vibra Finish
 

Cassandra and Docker Lessons Learned

  • 1. Cassandra and Docker Two buzzwords or a match made in heaven? instaclustr.com @Instaclustr
  • 2. Who am I and what do I do? • Ben Bromhead • Co-founder and CTO of Instaclustr -> www.instaclustr.com <sales> • Instaclustr provides Cassandra-as-a-Service in the cloud. • Currently in AWS, Azure and Google Cloud in private beta with more to come. • We currently manage 50+ nodes for various customers, who do various things with it. </sales>
  • 3. Objectives • A quick intro on docker. • Why docker matters and how it works. • Working with Cassandra and docker. • Running C* in a constrained env w/ docker
  • 4. The Challenge Static website Web frontend DB Queue Background workers API endpoint nginx 1.5 + modsecurity + openssl + bootstrap 2 Java + Cassandra + Spark Ruby + Rails + sass + Unicorn Redis + redis-sentinel Python 3.0 + celery + pyredis + libcurl + ffmpeg + libopencv + nodejs + phantomjs Python 2.7 + Flask + pyredis + celery + psycopg + postgresql-client DevelopmentVM QA server Public Cloud Disaster recovery Contributor’s laptop Production Servers Mul$plicity*of*Stacks* Mul$plicity*of* hardware* environments* Production Cluster Customer Data Center Do*services*and*apps* interact* appropriately?* Can*I*migrate* smoothly*and* quickly?*
  • 5. Static website Web frontend Background workers DB Analytics Queue Developmen t VM QA Server Single Prod Server Onsite Cluster Public Cloud Contributor’ s laptop Customer Servers ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? Dependency madness
  • 7. Also a dependency mess ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?
  • 8. Solution: Intermodal Shipping containers Mul$plicity*of*Goods* Mul$plicity*of* methods*for* transpor$ng/storing* Do*I*worry*about* how*goods*interact* (e.g.*coffee*beans* next*to*spices)* Can*I*transport* quickly*and*smoothly* (e.g.*from*boat*to* train*to*truck)* …in between, can be loaded and unloaded, stacked, transported efficiently over long distances, and transferred from one mode of transport to another! A standard container that is loaded with virtually any goods, and stays sealed until it reaches final delivery.!
  • 9. Docker, shipping containers for code Static website Web frontendUser DB Queue Analytics DB Development VM QA server Public Cloud Contributor’s laptop Mul$plicity*of*Stacks* Mul$plicity*of* hardware* environments* Production Cluster Customer Data Center Do*services*and*apps* interact* appropriately?* Can*I*migrate* smoothly*and*quickly* …that can be manipulated using standard operations and run consistently on virtually any hardware platform ! An engine that enables any payload to be encapsulated as a lightweight, portable, self-sufficient container…!
  • 10. Solves the deployment dependency matrix Static website Web frontend Background workers User DB Analytics DB Queue Developmen t VM QA Server Single Prod Server Onsite Cluster Public Cloud Contributor’ s laptop Customer Servers
  • 11. Why docker matters • Finally Developers have a solution to build once and deploy anywhere • Finally Ops/Admin has a solution to configure anywhere • Finally DevOps is easy • Dev == Test == Staging == Production • Move with speed
  • 12. Docker, how it works. • Runs anywhere (Linux kernel 2.6.32+) • Uses lightweight VMs: • Own process space (namespace) • Process isolation and resource control (cgroups) • Own network adapter • Own filesystem (chroot) • Linux Analog to Solaris Zones, *BSD jails
  • 13. Docker, how it works. • Difference between a container and a VM Virtual Machine Container
  • 14. Docker, how it works. • What about the packaging component? • Uses Union filesystem to create a git like workflow around your deployed code: ! ! Docker! Container! Image! Registry! Push% ! ! ! ! Bins/! Libs! ! ! ! ! App! A! App!Δ!! ! ! ! ! Bins/! Docker'Engine' Docker'Engine' Update' Host'is'now'running'A’’' ' App'Δ'' ' ' ' ' Bins/' ' ' ' ' Bins/' Libs' ' ' ' ' App' A' ' ' ' ' Bins/' ' ' ' ' Bins/' Libs' ' ' ' ' App' A’’' Host'running'A'wants'to'upgrade'to'A’’.' Requests'update.'Gets'only'diffs' '
  • 15. Docker is it production ready?
  • 16. Cassandra and Docker • So how do we get on board the hype train? Without killing performance or stability? • Build Cassandra in a docker container, run it, then test. • Run in dev to get comfortable with it. • Talk to others who use it in production • https://github.com/docker/docker/issues - You will spend a lot of time here
  • 17. Docker + Networking • 1st attempt, throughput dropped in half! • Writes sucked, streaming sucked, what was going on? • Quick check with iperf showed a 50% hit in throughput • Docker uses Linux Ethernet Bridges for basic software defined routing. This will hose your network throughput. • Use the host network stack instead (—net=host), only saw a ~10% hit on network performance
  • 18. Docker + Networking • Docker uses Linux Ethernet Bridges for basic software defined routing. This will hose your network throughput. • Use the host network stack instead (—net=host), only saw a ~10% hit on network performance • Also solves NAT issues in an AWS like networking environment.
  • 19. Docker + Filesystem • Don’t want to throw it out when you upgrade/stop container. • Use volume mount folders to the underlying host!
  • 20. Docker + Filesystem • The filesystems (AUFS, BTRFS etc) that bring great benefits to Dockers workflow around building and snapshoting containers are not very good for databases. • UnionFS (AUFS) is terrible for writing lots of big files. • BTRFS is a pain to use from an ops point of view. • Hooray volume mounts use the underlying filesystem.
  • 21. Docker + Process Capabilities • Mlockall permission denied? A process needs CAP_IPC_LOCK & RLIMIT_MEMLOCK in order to perform this operation. By default docker doesn't assign this to a running container… • Can’t use native memory. Cassandra becomes slooow. • Can use --privileged and be done with it. Kind of lazy though • Use --cap-add instead
  • 22. Docker + SIGTERM propagation • When stopping the process docker will send a SIGTERM. • PID 1 does not have default signal handlers! • Bad if you use a bash script to launch Cassandra Images shameless copied from https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/
  • 23. Docker + SIGTERM propagation • Java to the rescue! • Make sure you run the cassandra bash script with -f (foreground) • exec causes the JVM to replace the bash process… making the world a happier place
  • 24. Docker + SIGTERM propagation • Tools like OpsCenter Server will have trouble with this. • Can be fixed using a wacky combination of trap and wait stanzas in your OpsCenter Server script (see http://veithen.github.io/ 2014/11/16/sigterm-propagation.html) • But now you have a bash script that duplicates init/systemd/ supervisord • The debate rages on…
  • 25. Docker + CoreOS • Docker + fav OS + CM?, CoreOS + etcd, Swarm + Machine, Deis etc • We chose CoreOS (Appeared to be sane, etcd is cool, systemd if you are into that kind of thing)
  • 26. Docker + CoreOS • Disable automatic updates + restarts (seriously do this) • Fix logging, otherwise you will log to 3 locations (/var/log/ cassandra, journalctl and dockers json based log • JVM will exit with error 143 (128 + 15 for SIGTERM). Need to ignore that in your systemd service definition.
  • 27. Docker + Dev Env • Docker relies on Linux kernel capabilites… so no native docker in OS X • We use OSX for dev, so we run vagrant and the CoreOS vagrant file https://github.com/coreos/coreos-vagrant • Look at https://github.com/tobert/cassandra-docker for something more off the shelf
  • 28. Docker + C* + Dev Env • How do I run lots of C* instances on a VM or my dev laptop without it falling over? • Make it run as slowly, but as stable as possible! • This is actually a great learning exercise as you discover a lot about how Cassandra works under the hood.
  • 29. Docker + C* + Dev Env • Set Memory to be super low, edit your cassandra-env.sh: MAX_HEAP_SIZE="128M"   HEAP_NEWSIZE="24M"
  • 30. Docker + C* + Dev Env • Tune compaction to have free reign and to smash the disk concurrent_compactors:  1   in_memory_compaction_limit_in_mb:  2   compaction_throughput_mb_per_sec:  0
  • 31. Docker + C* + Dev Env • Let’s use HSHA thrift server as it reduces the memory per thread used. rpc_server_type:  hsha
  • 32. Docker + C* + Dev Env • The HSHA server also lets us limit the number of threads serving in flight requests, but still have a large number of clients connected. concurrent_reads:  4   concurrent_writes:  4   rpc_min_threads:  2   rpc_max_threads:  2 • You can play with these to get the right numbers based on how your clients connect, but keep them low.
  • 33. Docker + C* + Dev Env • This is Dev! Caches have no power here! key_cache_size_in_mb:  0   reduce_cache_sizes_at:  0   reduce_cache_capacity_to:  0
  • 34. Docker + C* + Dev Env • How well does this work?!?! • Will survive running the insane workload in the c* 2.1 new stresstest tool. • We run this on AWS t1.micro instances • Sign up at https://www.instaclustr.com and give our new Developer nodes a spin!
  • 35. Go forth and conquer! Questions?