85
Cloud Optimization & DevOps Best Practices for Startups Presented by Ali Hussain February 3, 2015 Texas DevOps Houston Meetup

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

  • Upload
    flux7

  • View
    1.196

  • Download
    0

Embed Size (px)

Citation preview

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

Cloud Optimization & DevOps Best Practices for Startups

Presented by Ali Hussain

February 3, 2015

Texas DevOps Houston Meetup

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

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:

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

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

Quick Poll

HOW MANY?

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

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

Quick Poll

HOW MANY?

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

Cloud Computing has turned computing into a UTILITY.

Changes to Computer Thinking - Stephen Fry Explains Cloud Computing

A Must See!

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

Cloud Offers the Traditional

Compute Network Storage

Compliance Security Reliability Scalability

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

Pay-Per-Use Dynamic Scale Processing, Storage &

Memory

… and Cloud Promises

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

… and Cloud Also Allows

Push-Button Deployment of Infrastructure

Inclusive of everything from:

Security

App & Database Servers

Load Balancing

SOA

Queues

Data Processing

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

… and Cloud Opens Possibilities of

True automated infrastructure management.

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

On-demand use of 3rd-party tools.

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

“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?

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

What rules need to be

changed to leverage

these benefits?

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

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

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

2. Automate, not “Documate”

Automate the creation of the network

Installation of software

Error detection

Error handling

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

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

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

Docker & DevOps

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

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.

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

Docker is Attracting Investors!

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

Today’s Agenda

Basic Concepts & Docker

Terminology

Docker in the Real World

[as implemented

by Flux7]

Docker Hands-on Tutorial

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

Today’s Agenda

Docker in the Real World

[as implemented

by Flux7]

Docker Hands-on Tutorial

Basic Concepts & Docker

Terminology

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

Lightweight Portability Cross-Cloud Infrastructure

Docker’s Attraction Is in Its

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

But ... Why Docker?

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

Sounds Familiar?

Ineffective code pipeline management

Inconsistency across environments

Mismatches in dev & prod environments

Resource provisioning takes ages

Increasing bills

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

Build Once, Configure Once & Run Anywhere

Docker in Terms of Docker ...

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

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.

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

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.

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

Today’s Agenda

Basic Concepts & Docker

Terminology

Docker in the Real World

[as implemented

by Flux7]

Docker Hands-on Tutorial

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

Docker Hands-On

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

Installation

Install VMWare from USB stick

Install the Linux image from USB stick

Install Docker

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

The BusyBox Test

Pull busybox container

Run is inside of Docker

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

Docker run

Run with only the main process

Run interactively

Run in daemon mode

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

Docker diff

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

Docker commit

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

Docker create

Using Dockerfile

Tips on Dockerfile

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

DockerHub

Create a new repo

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

Docker push

Pushing a container to Dockerhub

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

Volumes

Create container with 2 volumes

Mount Data volumes into application container

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

Port Forwarding

Auto-map all exposed ports to host

Binding a port to a host interface

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

DockerFile

# sshd## VERSION 0.0.1

FROM ubuntuMAINTAINER Thatcher R. Peskens "[email protected]"

# 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

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

Today’s Agenda

Docker in the Real World

[as implemented

by Flux7]

Basic Concepts & Docker

Terminology

Docker Hands-on Tutorial

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

Docker in the Real-World

Simplifying Configuration

Developer Productivity

Multi-Tenancy

Server Consolidation

App Isolation

Code Pipeline Management

Debugging Capabilities

Rapid Deployment

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

Australia’s 5th largest solar panel installer

Application: Solar Panel Monitoring

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

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

Business Problem

Low customer engagement ⇒ limited upsell opportunities

Unhappy customers stuck with large electricity bills

Low collection rates on leased units

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

Measure power output at solar panels Store data

Create reports

Status Indicator

Monitoring

Mail

Customer 1 Customer 2

Customer n

Controlling

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

Customer 2Customer 1

Measure power output at solar panels

Customer n

Status Indicator

Monitoring

Mail

Store dataCreate reports

Controlling

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

Mail

Status Indicator

Monitoring

Mail

Store dataCreate reports

Customer 2Customer 1

Measure power output at solar panels

Customer n

Controlling

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

Multi-tenancy

Scenario

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

The Dev SolutionAdd Tenant ID in Code & Database

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

Tedious Error Prone Code

Changes

Downsides

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

The Ops Solution

New set of servers per tenant

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

Low Utilization High Cost

Downsides

High Maintenance

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

Page load time

Why Not Leaner Servers?

> 5 seconds

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

The DevOps Solution

New Docker containers for every tenant

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

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

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

DevOps

Take Aways

Dev or Ops alone >

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

Case Study 2: Improved Developer Workflow Using Docker

Application: National & International Automotive Listing

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

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

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

Local Dev Environment That Matches Prod

The “Holy Grail” of dev environment management

NOW possible in all its complexity due to Docker.

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

Why Developer Workflow?

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

Web Developer Workflow

Developer Local Test QA Production

Least expensive, but most executed

Most expensive, but least executed

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

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

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

Developer Environment Must Be ...

Quick Production-like Repeatable

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

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.

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

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

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

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

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

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

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

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.

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

Our Solution

Developer Local Test QA Production

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

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

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

AppWeb

DB

LogStashMem

$

HTTP

SSH

Virtualbox VM

App Code and Logs

Laptop

devenv.sh for interacting with

the setup

Docker Containers

Redis

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

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”

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

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

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

Why We Used Docker?

Minimal Performance

Overhead

Fast Boot & Shutdown

Smaller files sizes & ability to diff

containers

Container will run in the

Cloud

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

Variation: Today

Developer Local Test QA Production

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

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

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

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

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

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

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

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

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

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

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

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.

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

Application: 3D Printing

Case Study 3: Efficient & Easy Code Deployment Using Docker

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

Problems

Deploy code conveniently to production from laptop

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

Setup

Use Dockerhub as code delivery mechanism

A staging environment & a Production environment in AWS

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

Process

Build containers in staging; test &

push to DockerHub

Push triggers a pull of containers on instances

Containers are killed & new

containers are started

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

Other Docker Projects Flux7Has Impacted

Trucking Office

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

Thank You!

Twitter: @Flux7Labs

Blog: blog.flux7.com