2016 OSCON - Containers

46
8/16/2019 2016 OSCON - Containers http://slidepdf.com/reader/full/2016-oscon-containers 1/46 Developing Just Got Easier ! Really! Powering New Opportunities at Scale

Transcript of 2016 OSCON - Containers

Page 1: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 1/46

Developing Just Got

Easier ! Really!

Powering New Opportunities at Scale

Page 2: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 2/46

2Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Containers + Databases = Happy Developers

Ephemeral Containers + Databases = DevOps headaches

4 Things you must use to evaluate

!  Data Redundancy

Dynamic Self Discovery & Cluster formation

!  Self Healing (as containers enter and leave)

!  Application Tier discovery of Database Cluster

Conclusion

Page 3: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 3/46

3Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Part One"Here's another nice mess you have

got me into"Laurel & Hardy circa 1929

Page 4: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 4/46

4Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Existing Architectures Are Broken

Challenges

• 

Complex

• 

Maintainability

• 

Durability

• 

Consistency

• 

Scalability

• 

Cost ($)

• 

Data Lag

Caching Layer

Operational Database

Real-timeConsumer Facing

Pricing /Inventory / Billing

Real-timeDecisionin

g

StreamingData

Legacy Database(Mainframe)

RDBMSDatabase

TransactionalSystems

Enterprise Environment

LegacyRDBMS

HDFS BASED

Page 5: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 5/46

5Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Existing Deployment Models Are Broken

Developer

Versioncontrol

1. Development 2. Test 3. Stage / Production

QA / QE Sysadmin

Page 6: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 6/46

6Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Infrastructure Cannot be Fully UtilizedTRADITIONAL DATABASE

OS FILE SYSTEM

PAGE CACHE

BLOCK INTERFACE

SSD HDD

What You Have

BLOCK INTERFACE

SSD SSD

OPEN NVM

SSD

DATABASE

MEMORY SYSTEM

•  Direct device access

•  Large Block Writes

•  Indexes in DRAM

•  Highly Parallelized

What You Want

Page 7: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 7/46

Part TwoContainers

Page 8: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 8/46

9Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Container Mission – Reduce Complexity

Build Ship Run

!"#$ &'($)(*)+

,-./01$2

,-(34*/Clustering Distribution

Image specContainer run-time spec

Runtime

Trust

Page 9: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 9/46

10Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Encapsulation of Dependencies

O/S packages & Patches

!  Execution environment (e.g. Python 2.7)

!  Application Code & Dependencies

Process Isolation

Isolate the process from anything else running

Faster, Lightweight virtualization

What do Containers give me?

Page 10: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 10/46

11Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Containers vs. Virtual machines

Page 11: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 11/46

12Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

FROM python:2.7

 ADD . /code

 WORKDIR /code

RUN apt-get update

RUN apt-get -y install python-dev

RUN apt-get -y install libssl-dev

RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 5000

CMD python app.py

Dockerfile - Example

Page 12: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 12/46

13Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Coalition of industry leaders join forces to eliminate

fragmentation

•  Form a vendor-neutral, open source governance model under the

Linux Foundation

• 

Establish common standards for container format and runtime

• 

Docker donated its container format, runtime and associated

specifications

• 

Appoint maintainers for the libcontainer project

Open Container Initiative (OCI) – Polyglot Vendors

http://www.opencontainers.org/

Page 13: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 13/46

14Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Docker Landscape in Pictures

Machine provisionsDocker Engines

Swarm clusters

Docker Engines

Compose orchestrates

Container deployment

Containers are runby Docker Engine

Docker Machine Docker Compose

Docker Swarm

Docker Engine

Container

Containers encapsulatesyour code, dependencies…

Page 14: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 14/46

Part Three – AerospikeThe Enterprise NoSQL Database

Page 15: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 15/46

16Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

The Bottom Line

Page 16: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 16/46

17Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.17 

Built for Flash

•  Primary Key index in parentless Red-Black tree in DRAM

•  Data in DRAM or SSD

• 

Secondary B-Tree indexes in SSD

•  Proprietary Log Structured File system

•  Parallelize reads/writes to multiple SSDs

•  Self-managing nodes of adistributed database cluster

•  Cluster-node load balancing in a

distributed system

•  Hybrid DRAM-SSD memory

system

•  Real-time transaction scheduling

•  Still requires specificoptimizations

• 

High IOP and durability NVMe

required by customers

•  Excellent working relationship

with Intel for Xpoint on DDR

Utilization Fundamental IP X Point

Page 17: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 17/46

18Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Master-Based Clustering

18 

High Availability High Consistency Architecturally

Correct

• 

Fits the architecture

• 

Demanded by Enterprise

customers

• 

 Aerospike’s HA reputation isunmatched

• 

Cross Data Center replication(XDR) for HA/DR

• 

FinServ and Telecom

customers using application-level hot standby

• 

Extends to Conflict Resolution

• 

Hybrid Peer-to-Peer withMaster

• 

Provides either Availabilityor Consistency

• 

Mastering is required for

transaction correctness

• 

Sync writes within a

Cluster

Page 18: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 18/46

19Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.19 

Developer Experience

• 

Frameworks

• 

SpringData

• 

Play

• 

Connectors•

 

JDBC

• 

Spark / Hadoop

• 

Schema free

• 

Geospatial

• 

List & Map server-side

manipulation•

 

Secondary Indexes

• 

Docker integration

• 

Orchestration (Mesos,

Kubernetes) – in progress

• 

IPv6 - in progress•

 

Security with transportencryption, certificate based

authentication (in progress)

Rich & Simple Integration Deployment

Page 19: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 19/46

22Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Challenge•  Overall SLA 750 ms

• 

Loss of business due to latency

• 

Every credit card transaction requires

hundreds of DB reads/writes

Need to Scale Reliably• 

10 100 TB

• 

10B 100 B objects

• 

200k I Million+ TPS

Aerospike In-Memory NoSQL•  Built for Flash

• 

Predictable low latency at high throughput

• 

Immediate consistency, no data loss

• 

Cross data center (XDR) support• 

20 server cluster

• 

Dell 730xd w/ 4NVMe SSDs

Credit Card Processing System

Fraud Detection & Protection App

RulesRule 1Rule 2Rule 3

Historical Data

Rule 1-PassedRule 2-Passed

Rule 3-Failed

 Account Behavior

Static Data

 Account Statistics

Real-time Fraud Prevention 

Page 20: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 20/46

23Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Cloud Deployment: 1 Million Writes/Sec on

Google Compute

Aerospike hits 1M writes/sec with 6x fewer servers than Cassandra

Delivers consistent low latency with no jitter for both read and writeworkloads

300 nodes50 nodes

New results: 20 nodes, and 4M reads per second

Page 21: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 21/46

24Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

1 Aerospike Server, Not 12 Redis Shards

Page 22: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 22/46

Part Four Aerospike and Docker

Page 23: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 23/46

26Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Data Redundancy

Containers are Ephemeral – Need more than one copy of the data

Dynamic Self Discovery & Cluster formation

!  Need to start and stop Conatiners when needed

Clusters needs to grow and shrink dynamcially

Self Healing

Loss of nodes must not be fatal to the cluster integrity

!  Addition of nodes must scale capacity

Application Tier discovery of Database Cluster

 Automatic discovery of nodes!  Automatic routing of requests to the correct nodes

Requirements

Page 24: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 24/46

27Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Data Redundancy

 Automatic Replication of Data to "n" nodes

Dynamic Self Discovery & Cluster Formation

!  Shared nothing architecture – all nodes equal

Multi-cast & Mesh Networking models

Self Healing

 Automatic hashing of keys across the cluster & rebalancing

!  RIPEMD-160 collision free algorithm with Smart Partitions™

Application Tier discovery of Database Cluster

 Automated cluster discovery with Smart Client™!  Java, C/C++, C#, Python, Node.js

Example: Aerospike and Docker

Page 25: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 25/46

Part FiveDemo

Page 26: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 26/46

29Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Build & Run an App in Development

Python + Aerospike

Deploy to a Swarm cluster in Production

!  Add more Web containers behind HAProxy

Scale Aerospike Cluster in production

!  Add more Database nodes

Demo: Development through to Production

Page 27: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 27/46

30Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Lets build an App!

web

Aerospike

Development

python / flask

Page 28: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 28/46

31Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Scale in Production

web2 web3 web4 webNweb web1

Aerospike

Development

!

 

Production

HA Proxy

asd1 asdNasd2 ! 

Page 29: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 29/46

32Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Demo 1 : Build an App

Page 30: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 30/46

33Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

FROM python:2.7

 ADD . /code

 WORKDIR /code

RUN apt-get update

RUN apt-get -y install python-dev

RUN apt-get -y install libssl-dev

RUN pip install --no-cache-dir -r requirements.txt

EXPOSE 5000

CMD python app.py

Dockerfile

Page 31: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 31/46

34Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

 web:

 build: .

 ports:

- "5000:5000"

links:

- aerospike

hostname: dev.awesome-counter.com

environment:

- AEROSPIKE_HOST=dev_aerospike_1

aerospike:

image: aerospike/aerospike-server:latest

volumes:- $PWD:/etc/aerospike

docker-compose.yml

Page 32: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 32/46

35Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Roll the App to Production behind HA Proxy

web web1

Development Production

Aerospike

HA Proxy

Aerospike

Page 33: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 33/46

36Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Scale the web tier

web2 web3web4

webNweb web1

Aerospike

Development

!

 

Production

Aerospike

HA Proxy

Page 34: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 34/46

37Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Docker Networking

Page 35: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 35/46

38Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Demo 2 : Scale the Web Tier

Page 36: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 36/46

39Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

discovery:

image: aerospike/interlock:latest

environment:

- "DOCKER_HOST"

volumes:- "/var/lib/boot2docker:/etc/docker"

command: "... --plugin aerospike start"

aerospike:

image: aerospike/aerospike-server:latest

volumes:- "$PWD:/etc/aerospike"

aes_base_cluster.yml

Page 37: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 37/46

40Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

haproxy:

extends:

file: haproxy.yml

service: haproxy-server

environment:

- "constraint:node==swarm-0"

net: bridge

 web:

image: alvinr/demo-webapp-as:latest

extends:

file: haproxy.yml

service: haproxy-app

environment:- AEROSPIKE_HOST=prod_aerospike_1

net: prod

docker-compose.yml

aerospike:

extends:

file: aes_base_cluster.yml

service: aerospike

image: aerospike/aerospike-server:3.7.1

labels:

- "com.aerospike.cluster=awesome-counter"

environment:

- "affinity:com.aerospike.cluster!=awesome-counter"

net: prod

Page 38: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 38/46

41Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Scale the Aerospike cluster

web2 web3web4

webNweb

web1

mongodb

Development

!

 

Production

HA Proxy

asd1 asdNasd2 ! 

Page 39: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 39/46

42Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Demo 3 : Scale the Cluster

Page 40: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 40/46

43Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

API for Docker Events

Start / Stop / Die etc

!  https://docs.docker.com/engine/

reference/api/docker_remote_api/

!

 

Interlock – Evan Hazlett! 

Framework to listen and publish events

!  Plugin Framework (e.g. HAPROXY)

https://github.com/ehazlett/interlock

Aerospike Interlock plugin

!  Add / Remove node from Cluster

https://github.com/aerospike/interlock

Docker Event API & Interlock

Page 41: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 41/46

44Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

https://github.com/aerospike/interlock

func (p AerospikePlugin) runAsinfoTip(args ...string) bool{

asinfo, err := exec.LookPath("asinfo")

if err != nil{

log.Errorf("error finding asinfo binary: %s", err)

return false

}

time.Sleep(time.Second*5) //sleep 5s for ASD to be ready

cmd := exec.Command(asinfo,args...)

Interlock Plugin - Aerospike

Page 42: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 42/46

45Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Part SixConsiderations & Conclusion

Page 43: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 43/46

46Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Inside

!  Encapsulation of Concerns

Storage: Inside or outside the container?

Host

daemon

container

Host

daemon

container e.g.SSD

e.g.EBS

 /data/db

 /mnt/xx:/data/db

/dev/xvdb 

Outside

Separation of Concerns

Storage Features (e.g.Snapshots)

Page 44: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 44/46

47Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Data Container

--volumes-from <container name>

!  Managed like other containers

Special rules for Destruction

!  TBD: Performance

Storage: Data Container?

Host

daemon

container

Host

daemon

container

Page 45: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 45/46

48Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Summary

• 

Define Container, their contents and how they work together once

• 

Deploy the same images in Dev, Pre-Prod and Production across

Platforms

One solution from Dev -> Production

• 

Ops define the whitelisted images, security policies etc.

• 

Dev use approved images to build upon

• 

Eliminate the complexity (and cost) of deployment•

 

Scale up & down in a Flexible and Simple way

Running Docker & Database in Production

Page 46: 2016 OSCON - Containers

8/16/2019 2016 OSCON - Containers

http://slidepdf.com/reader/full/2016-oscon-containers 46/46

49Proprietary & Confidential | © 2015 Aerospike Inc. All rights reserved.

Code

http://github.com/alvinr/docker-demo/tree/master/aerospike

Docker Images

!  http://hub.docker.com/r/aerospike/

Aerospike & Docker deployment guide!  http://www.aerospike.com/docs/deploy_guides/docker/

Contact me!

[email protected]

!  @jonnyeight

Thanks and Q&A