Cloud Optimization and DevOps Best Practices for Startups Houston Meetup Feb 3, 2015

Post on 16-Jul-2015

1,191 views 0 download

transcript

Cloud Optimization & DevOps Best Practices for Startups

Presented by Ali Hussain

February 3, 2015

Texas DevOps Houston Meetup

Today’s Presenter:Ali Hussain

Co-founder & CTO Flux7

Flux7: Cloud and DevOps Solutions

Automated self-healing AWS frameworks

Enterprise DevOps management

AWS Certified Team

Clients:Partners:

★ Front-end HTML / JS Developers★ Backend Developers★ Operations Folks ★ Dev & Ops★ Business: Executives / Managers

Quick Poll

HOW MANY?

★ Enterprise [ > 1B in cap ]★ Mid-tier★ SMBs

Quick Poll

HOW MANY?

Cloud Computing has turned computing into a UTILITY.

Changes to Computer Thinking - Stephen Fry Explains Cloud Computing

A Must See!

Cloud Offers the Traditional

Compute Network Storage

Compliance Security Reliability Scalability

Pay-Per-Use Dynamic Scale Processing, Storage &

Memory

… and Cloud Promises

… and Cloud Also Allows

Push-Button Deployment of Infrastructure

Inclusive of everything from:

Security

App & Database Servers

Load Balancing

SOA

Queues

Data Processing

… and Cloud Opens Possibilities of

True automated infrastructure management.

[error handling, disaster recovery, self-healing, auto-scaling]

On-demand use of 3rd-party tools.

“New technologies provide benefit only if

you drop the rules that were designed to

overcome the shortcomings of the old

technology.” ~ Dr. Eliyahu Goldratt

HOW DOES ONE LEVERAGE THESE

BENEFITS?

What rules need to be

changed to leverage

these benefits?

1. View Servers as Cattle, Not Pets

● Have numbers assigned

● Are usually identical

● Replaced when not in good health

● You need more, you buy more

● Has a personalized name

● Unique, special & cared for

● Taken care of when ill

Src: Gavin McCance from CERN

2. Automate, not “Documate”

Automate the creation of the network

Installation of software

Error detection

Error handling

3. Rent, Not Buy

Leverage 3rd-party services on-demand

Firewalls, monitoring, logging can be achieved with a few clicks

Service registry & discovery can be achieved via cloud APIs

Docker & DevOps

First ... Why Learn Docker?

Fastest-growing IT technology I have seen

in my career

50K+ downloads in less than 30 days of public

introduction

More than 100 Fortune 500s are toying with

Docker already

Docker is impacting the way we code, the way we test, and the way we deliver.

Docker is Attracting Investors!

Today’s Agenda

Basic Concepts & Docker

Terminology

Docker in the Real World

[as implemented

by Flux7]

Docker Hands-on Tutorial

Today’s Agenda

Docker in the Real World

[as implemented

by Flux7]

Docker Hands-on Tutorial

Basic Concepts & Docker

Terminology

Lightweight Portability Cross-Cloud Infrastructure

Docker’s Attraction Is in Its

But ... Why Docker?

Sounds Familiar?

Ineffective code pipeline management

Inconsistency across environments

Mismatches in dev & prod environments

Resource provisioning takes ages

Increasing bills

Build Once, Configure Once & Run Anywhere

Docker in Terms of Docker ...

Docker Components & Elements

Docker Client is the user interface that allows communication between the user

and the Docker daemon.

Docker Daemon sits on the host machine answering requests for services.

Docker Index is a centralized registry allowing backup of Docker container

images with public and private access permissions.

Docker Components & Elements

Docker Containers are the actual containers running the applications and includes the operating system, user added files and meta-data.

Docker Images are all inclusive images that help launch Docker containers.

DockerFile is a file containing instructions that help automate image creation.

Layer: Each file system that is stacked when Docker mounts rootfs.

Today’s Agenda

Basic Concepts & Docker

Terminology

Docker in the Real World

[as implemented

by Flux7]

Docker Hands-on Tutorial

Docker Hands-On

Installation

Install VMWare from USB stick

Install the Linux image from USB stick

Install Docker

The BusyBox Test

Pull busybox container

Run is inside of Docker

Docker run

Run with only the main process

Run interactively

Run in daemon mode

Docker diff

Docker commit

Docker create

Using Dockerfile

Tips on Dockerfile

DockerHub

Create a new repo

Docker push

Pushing a container to Dockerhub

Volumes

Create container with 2 volumes

Mount Data volumes into application container

Port Forwarding

Auto-map all exposed ports to host

Binding a port to a host interface

DockerFile

# sshd## VERSION 0.0.1

FROM ubuntuMAINTAINER Thatcher R. Peskens "thatcher@dotcloud.com"

# make sure the package repository is up to dateRUN echo "deb http://archive.ubuntu.com/ubuntu precise main universe" > /etc/apt/sources.listRUN apt-get update

RUN apt-get install -y openssh-serverRUN mkdir /var/run/sshd RUN echo 'root:screencast' |chpasswd

EXPOSE 22CMD /usr/sbin/sshd -D

Dockerfile to set up an sshd service in a container

Today’s Agenda

Docker in the Real World

[as implemented

by Flux7]

Basic Concepts & Docker

Terminology

Docker Hands-on Tutorial

Docker in the Real-World

Simplifying Configuration

Developer Productivity

Multi-Tenancy

Server Consolidation

App Isolation

Code Pipeline Management

Debugging Capabilities

Rapid Deployment

Australia’s 5th largest solar panel installer

Application: Solar Panel Monitoring

Case Study 1: Quick & Easy Multi-tenancy Using Docker

Business Problem

Low customer engagement ⇒ limited upsell opportunities

Unhappy customers stuck with large electricity bills

Low collection rates on leased units

Measure power output at solar panels Store data

Create reports

Status Indicator

Monitoring

Mail

Customer 1 Customer 2

Customer n

Controlling

Customer 2Customer 1

Measure power output at solar panels

Customer n

Status Indicator

Monitoring

Mail

Store dataCreate reports

Controlling

Mail

Status Indicator

Monitoring

Mail

Store dataCreate reports

Customer 2Customer 1

Measure power output at solar panels

Customer n

Controlling

Multi-tenancy

Scenario

The Dev SolutionAdd Tenant ID in Code & Database

Tedious Error Prone Code

Changes

Downsides

The Ops Solution

New set of servers per tenant

Low Utilization High Cost

Downsides

High Maintenance

Page load time

Why Not Leaner Servers?

> 5 seconds

The DevOps Solution

New Docker containers for every tenant

Inexpensive

Up to 30 tenants per large AWS

instance

Page loads under 1 second

Benefits

Fast

Implemented in under 2 weeks with NO code changes

DevOps

Take Aways

Dev or Ops alone >

Case Study 2: Improved Developer Workflow Using Docker

Application: National & International Automotive Listing

Auto.com’s “Big Plan” for Cloud

Push-Button Deployment of Infrastructure

Inclusive of everything from:

Security

App and Database servers

Load Balancing

SOA

Queues

Data Processing

Local Dev Environment That Matches Prod

The “Holy Grail” of dev environment management

NOW possible in all its complexity due to Docker.

Why Developer Workflow?

Web Developer Workflow

Developer Local Test QA Production

Least expensive, but most executed

Most expensive, but least executed

Development Environment

Developer Local Test QA Production

Least expensive, but most executed

Most expensive, but least executed

95% - 99% of developer time is

spent in the development environment

Developer Environment Must Be ...

Quick Production-like Repeatable

Production-like

Each tier runs same OS & software versions

Tiers are isolated from each other as in production

Tiers are isolated from the developers device

[A client] never realized they needed to run gem install bundle on a tier until we put the two services on different servers.

Production-like

Our URL: http://xxxx.xxxxxx.xxx is not loading in IE and Safari but is in

Chrome/Firefox. This is only in AWS QA and not in AWS DEV or PROD. We are

wondering if there is something in the infra that is causing this behavior.

-Thx

Quick

Waiting Frustration Distraction

“When I fire a local QA run in a mature project, it takes 8 mins. I check cricinfo.com and facebook while it runs.”

Developer at a Fortune 100 Company

Repeatable

Here is a Bash script to run on

your device

Follow these docs and ask away if any questions

Here is a Vagrant file

Install software PHP and MySQL on your device

Prone to human errors Prone to 3rd-party changes

Repeatable

Here is a Bash script to run on

your device

Follow these docs and ask away if any questions

Here is a Vagrant file

Install software PHP and MySQL on your device

Prone to human errors Prone to 3rd party changes

[A client] supported MySQL Percona v5.53x. Vendors updated the version to 5.54 and broke our software.

Our Solution

Developer Local Test QA Production

One Docker container for each application tier

Run a VM with folder sync & port forwarding

Installs Docker Downloads containers (if not available)

Used to bootstrap Docker containers in dev & AWS instances in prod

AppWeb

DB

LogStashMem

$

HTTP

SSH

Virtualbox VM

App Code and Logs

Laptop

devenv.sh for interacting with

the setup

Docker Containers

Redis

Result: We No Longer Hear ...

“works on my machine but not on yours”

“I have been helping the [new hire]

set up her environment all day”

“IT guys must do something differently in staging”

“I can’t try it because IT has not

updated the dev environment”

Who Sees the Benefit?

Backend Developers

● Homogenous environment● Quick feedback● Agile: break it fearlessly

Front-end HTML Devs

● Quick visual feedback with populated data

● Avoid installations

Ops

Only one standardized dev environment to support

Management

● Less conflict● Faster time to market● Happier engineers● Easier hiring

Why We Used Docker?

Minimal Performance

Overhead

Fast Boot & Shutdown

Smaller files sizes & ability to diff

containers

Container will run in the

Cloud

Variation: Today

Developer Local Test QA Production

Variation

Developer Local Test QA Production

Use Docker alone with boot2docker & Dockerfiles

Requires Docker in entire workflow, including prod

Docker will release version 1.0 soon

These Scripts Make a Working System

bootstrap_container

bootstrap_containers

build_base_image

build_from_scratch

clean_for_docker

copy_etc_hosts

create_etc_hosts

create_etc_hosts_for

deploy_app

help

plumb_container

plumb_containers

prep_vm

provision_container

push_etc_hosts

restart_container

restart_unicorn

retry_thrice

rm_containers

run_container

run_container_raw

run_containers

setup_ssh_keys

stop_container

stop_containers

A Full Production Database on a Laptop?

Multi-GB production database won’t run

on a laptop

Strategically sampled data set

The Solution

Rule: Development uses fresh production data

SQS Runs in Cloud … Not a Laptop

Production uses Amazon SQS

Rule #2: No AWS dependencies in Dev

Modified app to use RabbitMQ

Rule #1: Environment is identical in Dev to Prod

The Solution

Service Addressing in Dev

Production uses static IP addresses

dev uses / etc / hosts,

prod uses Route53

Rule: Service addressing transparent between Dev &

Prod for developers

The Solution

Automation Benefits

Innovation: Easier to innovate when cost of being wrong is low.

Continuity: Organizational ownership of operations knowledge; valuable for business continuity.

Faster Iteration: High fidelity & confidence in Dev; QA means faster iteration of product.

Talent: Willingness to experiment with advanced technology like Docker attracts talented contributors to our team.

Application: 3D Printing

Case Study 3: Efficient & Easy Code Deployment Using Docker

Problems

Deploy code conveniently to production from laptop

Setup

Use Dockerhub as code delivery mechanism

A staging environment & a Production environment in AWS

Process

Build containers in staging; test &

push to DockerHub

Push triggers a pull of containers on instances

Containers are killed & new

containers are started

Other Docker Projects Flux7Has Impacted

Trucking Office

Thank You!

Twitter: @Flux7Labs

Blog: blog.flux7.com