83
Understanding and designing web application deployment for small teams. Lee Hambley [email protected] github.com/leehambley twitter.com/codebeaker Sunday, October 16, 11

Mag rails 2011 web application deployment for small teams

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Mag rails 2011   web application deployment for small teams

Understanding and designing web application deployment for small

teams.

Lee [email protected]

github.com/leehambley

twitter.com/codebeaker

Sunday, October 16, 11

Page 2: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?

Sunday, October 16, 11

Page 3: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

Sunday, October 16, 11

Page 4: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

Sunday, October 16, 11

Page 5: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

Sunday, October 16, 11

Page 6: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

Sunday, October 16, 11

Page 7: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

• because we need to test something privately in a production-like environment

Sunday, October 16, 11

Page 8: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

• because we need to test something privately in a production-like environment

• because we’re professionals

Sunday, October 16, 11

Page 9: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

• because we need to test something privately in a production-like environment

• because we’re professionals

• because interpreters like to load files into memory for performance (& other good reasons)

Sunday, October 16, 11

Page 10: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

• because we need to test something privately in a production-like environment

• because we’re professionals

• because interpreters like to load files into memory for performance (& other good reasons)

• because we like to think about software in “versions”

Sunday, October 16, 11

Page 11: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

• because we need to test something privately in a production-like environment

• because we’re professionals

• because interpreters like to load files into memory for performance (& other good reasons)

• because we like to think about software in “versions”

• because we prefer to be available to our customers

Sunday, October 16, 11

Page 12: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

• because we need to test something privately in a production-like environment

• because we’re professionals

• because interpreters like to load files into memory for performance (& other good reasons)

• because we like to think about software in “versions”

• because we prefer to be available to our customers

• because we prefer to be accountable to the business people

Sunday, October 16, 11

Page 13: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

• because we need to test something privately in a production-like environment

• because we’re professionals

• because interpreters like to load files into memory for performance (& other good reasons)

• because we like to think about software in “versions”

• because we prefer to be available to our customers

• because we prefer to be accountable to the business people

• because we have things like migrations, seed tasks, background workers and all the rest

Sunday, October 16, 11

Page 14: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

• because we need to test something privately in a production-like environment

• because we’re professionals

• because interpreters like to load files into memory for performance (& other good reasons)

• because we like to think about software in “versions”

• because we prefer to be available to our customers

• because we prefer to be accountable to the business people

• because we have things like migrations, seed tasks, background workers and all the rest

• because there’s usually more than one machine

Sunday, October 16, 11

Page 15: Mag rails 2011   web application deployment for small teams

WHY DO WE DEPLOY?• Fundamentally, because we’ve done

some work, and we want to share it

• firstly with stakeholders, second with users

• because we’ve fixed bugs and need to make the improved code available

• because the business interest needs new features

• because we need to test something privately in a production-like environment

• because we’re professionals

• because interpreters like to load files into memory for performance (& other good reasons)

• because we like to think about software in “versions”

• because we prefer to be available to our customers

• because we prefer to be accountable to the business people

• because we have things like migrations, seed tasks, background workers and all the rest

• because there’s usually more than one machine

• because very often there’s more than one moving piece has changed. (code & database, code & configuration, etc)

Sunday, October 16, 11

Page 16: Mag rails 2011   web application deployment for small teams

WHAT SHOULD WE DEPLOY?

• How do we decide if a project really needs deployment?

• How do we decide what to deploy?

•Where does infrastructure end, and the application begin?

• How can the what change depending on the application?

•What don’t we deploy?

• Uploaded assets, the database, the system packages, the Ruby Gems, your own log files.

Sunday, October 16, 11

Page 17: Mag rails 2011   web application deployment for small teams

INFRASTRUCTURE VS. APPLICATION

rubygems.org

github.com

nginx virtual hosts configuration

scheduled jobs

log files

SSH keys

SSL Certificates

Infrastructure Application

operating system

application code

database configuration

cache configuration

logrotate configuration

Sunday, October 16, 11

Page 18: Mag rails 2011   web application deployment for small teams

BENCHMARKgadget-showdown.co.ukComparing the latest gadgets in ultimate-fighting style reviews, ending with a “Will it blend?” teardown. Request your own review of any two devices, and we’ll get right on it!

•User registration•User comments• Requests• RSS feed•Notifications•Daily posts•Non-technical writing team

Sunday, October 16, 11

Page 19: Mag rails 2011   web application deployment for small teams

BENCHMARKgadget-showdown.co.ukComparing the latest gadgets in ultimate-fighting style reviews, ending with a “Will it blend?” teardown. Request your own review of any two devices, and we’ll get right on it! PostgreSQL

Memcache

•User registration•User comments• Requests• RSS feed•Notifications•Daily posts•Non-technical writing team

Sunday, October 16, 11

Page 20: Mag rails 2011   web application deployment for small teams

BENCHMARKgadget-showdown.co.ukComparing the latest gadgets in ultimate-fighting style reviews, ending with a “Will it blend?” teardown. Request your own review of any two devices, and we’ll get right on it! PostgreSQL

Memcache

•User registration•User comments• Requests• RSS feed•Notifications•Daily posts•Non-technical writing team

Sunday, October 16, 11

Page 21: Mag rails 2011   web application deployment for small teams

BENCHMARKgadget-showdown.co.ukComparing the latest gadgets in ultimate-fighting style reviews, ending with a “Will it blend?” teardown. Request your own review of any two devices, and we’ll get right on it! PostgreSQL

Memcache

MRI v1.8.7

•User registration•User comments• Requests• RSS feed•Notifications•Daily posts•Non-technical writing team

Sunday, October 16, 11

Page 22: Mag rails 2011   web application deployment for small teams

BENCHMARKgadget-showdown.co.ukComparing the latest gadgets in ultimate-fighting style reviews, ending with a “Will it blend?” teardown. Request your own review of any two devices, and we’ll get right on it! PostgreSQL

Memcache

MRI v1.8.7

Unicorn

•User registration•User comments• Requests• RSS feed•Notifications•Daily posts•Non-technical writing team

Sunday, October 16, 11

Page 23: Mag rails 2011   web application deployment for small teams

BENCHMARKgadget-showdown.co.ukComparing the latest gadgets in ultimate-fighting style reviews, ending with a “Will it blend?” teardown. Request your own review of any two devices, and we’ll get right on it! PostgreSQL

Memcache

MRI v1.8.7

Unicorn

•User registration•User comments• Requests• RSS feed•Notifications•Daily posts•Non-technical writing team

Sunday, October 16, 11

Page 24: Mag rails 2011   web application deployment for small teams

WHO?Our hypothetical, inexperienced team.

Unlike us, they are not misunderstood masters of the forbidden and subtle arts. They’re not Jedi top-gun warlocks, like we are either, they’re just regular job people, and they’re never going to win a Nobel prize for their deployment efforts, and further more, they probably don’t even care.

Sunday, October 16, 11

Page 25: Mag rails 2011   web application deployment for small teams

WHO?Our hypothetical, inexperienced team.

Unlike us, they are not misunderstood masters of the forbidden and subtle arts. They’re not Jedi top-gun warlocks, like we are either, they’re just regular job people, and they’re never going to win a Nobel prize for their deployment efforts, and further more, they probably don’t even care.

Sunday, October 16, 11

Page 26: Mag rails 2011   web application deployment for small teams

WHO?Our hypothetical, inexperienced team.

Unlike us, they are not misunderstood masters of the forbidden and subtle arts. They’re not Jedi top-gun warlocks, like we are either, they’re just regular job people, and they’re never going to win a Nobel prize for their deployment efforts, and further more, they probably don’t even care.

• Three person development team• No dedicated “ops”• No deployment experience• No Unix experience

Sunday, October 16, 11

Page 27: Mag rails 2011   web application deployment for small teams

WHO?Our hypothetical, inexperienced team.

Unlike us, they are not misunderstood masters of the forbidden and subtle arts. They’re not Jedi top-gun warlocks, like we are either, they’re just regular job people, and they’re never going to win a Nobel prize for their deployment efforts, and further more, they probably don’t even care.

• Three person development team• No dedicated “ops”• No deployment experience• No Unix experience

• They want fast, reliable deployments• They don’t want phone calls at 3am because the

servers are choking• They don’t want to have to learn about unix to do

their job• They want it to be impossible to break something

accidentally• They don’t want to have to deal with passwords• They expect things to “Just Work” because they’re

hipster macbook using nancy boys.

Sunday, October 16, 11

Page 28: Mag rails 2011   web application deployment for small teams

WHERE DO WE DEPLOY?

✝ That’s not a condonation, just an observation

Sunday, October 16, 11

Page 29: Mag rails 2011   web application deployment for small teams

WHERE DO WE DEPLOY?

• Almost certainly to VPS

✝ That’s not a condonation, just an observation

Sunday, October 16, 11

Page 30: Mag rails 2011   web application deployment for small teams

WHERE DO WE DEPLOY?

• Almost certainly to VPS

• Almost certainly, not to EC2(that is, at least not in a way that makes the most of the elastic infrastructure)

✝ That’s not a condonation, just an observation

Sunday, October 16, 11

Page 31: Mag rails 2011   web application deployment for small teams

WHERE DO WE DEPLOY?

• Almost certainly to VPS

• Almost certainly, not to EC2(that is, at least not in a way that makes the most of the elastic infrastructure)

• Almost certainly to Ubuntu ✝ (because it has a convenient package manager)

✝ That’s not a condonation, just an observation

Sunday, October 16, 11

Page 32: Mag rails 2011   web application deployment for small teams

WHERE DO WE DEPLOY?

• Almost certainly to VPS

• Almost certainly, not to EC2(that is, at least not in a way that makes the most of the elastic infrastructure)

• Almost certainly to Ubuntu ✝ (because it has a convenient package manager)

• Probably to a VPS provider in the USA

✝ That’s not a condonation, just an observation

Sunday, October 16, 11

Page 33: Mag rails 2011   web application deployment for small teams

WHERE DO WE DEPLOY?

• Almost certainly to VPS

• Almost certainly, not to EC2(that is, at least not in a way that makes the most of the elastic infrastructure)

• Almost certainly to Ubuntu ✝ (because it has a convenient package manager)

• Probably to a VPS provider in the USA

• Probably to a 32 bit operating system

✝ That’s not a condonation, just an observation

Sunday, October 16, 11

Page 34: Mag rails 2011   web application deployment for small teams

WHERE DO WE DEPLOY?

• Almost certainly to VPS

• Almost certainly, not to EC2(that is, at least not in a way that makes the most of the elastic infrastructure)

• Almost certainly to Ubuntu ✝ (because it has a convenient package manager)

• Probably to a VPS provider in the USA

• Probably to a 32 bit operating system

• Probably to more than one machine

✝ That’s not a condonation, just an observation

Sunday, October 16, 11

Page 35: Mag rails 2011   web application deployment for small teams

WHERE DO WE DEPLOY?

• Almost certainly to VPS

• Almost certainly, not to EC2(that is, at least not in a way that makes the most of the elastic infrastructure)

• Almost certainly to Ubuntu ✝ (because it has a convenient package manager)

• Probably to a VPS provider in the USA

• Probably to a 32 bit operating system

• Probably to more than one machine

• Probably using something from AWS, because it’s hip

✝ That’s not a condonation, just an observation

Sunday, October 16, 11

Page 36: Mag rails 2011   web application deployment for small teams

WHERE DO WE DEPLOY?

• Almost certainly to VPS

• Almost certainly, not to EC2(that is, at least not in a way that makes the most of the elastic infrastructure)

• Almost certainly to Ubuntu ✝ (because it has a convenient package manager)

• Probably to a VPS provider in the USA

• Probably to a 32 bit operating system

• Probably to more than one machine

• Probably using something from AWS, because it’s hip

• Probably not using a CDN

✝ That’s not a condonation, just an observation

Sunday, October 16, 11

Page 37: Mag rails 2011   web application deployment for small teams

A SHORTLIST OF REQUIREMENTS FOR A SANE DEPLOYMENT

SpeedySecureAccessibleTransactionalAccountableParallellHookable

Sunday, October 16, 11

Page 38: Mag rails 2011   web application deployment for small teams

A SHORTLIST OF REQUIREMENTS FOR A SANE DEPLOYMENT

SpeedySecureAccessibleTransactionalAccountableParallelHookable

Sunday, October 16, 11

Page 39: Mag rails 2011   web application deployment for small teams

A SHORTLIST OF REQUIREMENTS FOR A SANE DEPLOYMENT

SpeedySecureAccessibleTransactionalAccountableParallelHookable

•Fast starting•Fail fast•Using a fast protocol (SSH, with keys)•Not wasting bandwidth or capacity•Not relying on passwords

Sunday, October 16, 11

Page 40: Mag rails 2011   web application deployment for small teams

A SHORTLIST OF REQUIREMENTS FOR A SANE DEPLOYMENT

SpeedySecureAccessibleTransactionalAccountableParallelHookable

•Using a secure protocol•Using a secure, trustworthy source•Secure from workstation to server•Secure deployment result by design•No shared sign-ons

•Robust•Resilient

•No .rc~ files

Sunday, October 16, 11

Page 41: Mag rails 2011   web application deployment for small teams

A SHORTLIST OF REQUIREMENTS FOR A SANE DEPLOYMENT

SpeedySecureAccessibleTransactionalAccountableParallelHookable

•Any member of the dev’ team can deploy•They can do it without using root (or other) passwords•Secure from workstation to server•Secure deployment result by design

Sunday, October 16, 11

Page 42: Mag rails 2011   web application deployment for small teams

A SHORTLIST OF REQUIREMENTS FOR A SANE DEPLOYMENT

SpeedySecureAccessibleTransactionalAccountableParallelHookable

•When a deploy fails on one machine, we fail it across the board•We know when a deploy starts, is in progress, and ends•We can inform our customers that there’s a deploy in progress,

without falling back to a maintenance page.•We can recover from errors.

Sunday, October 16, 11

Page 43: Mag rails 2011   web application deployment for small teams

A SHORTLIST OF REQUIREMENTS FOR A SANE DEPLOYMENT

SpeedySecureAccessibleTransactionalAccountableParallelHookable

•We know who deployed what, and when•We know exactly what happened during the deployment•We know which version of the code is in production

•We know how many servers are online

Sunday, October 16, 11

Page 44: Mag rails 2011   web application deployment for small teams

A SHORTLIST OF REQUIREMENTS FOR A SANE DEPLOYMENT

SpeedySecureAccessibleTransactionalAccountableParallelHookable

•We need to operate on our machines in parallel•Except when we don’t•Sequential parallel deployment

Sunday, October 16, 11

Page 45: Mag rails 2011   web application deployment for small teams

A SHORTLIST OF REQUIREMENTS FOR A SANE DEPLOYMENT

SpeedySecureAccessibleTransactionalAccountableParallelHookable

•We need to know how it worked out•We often need to share that information•with business people•with automated systems (issue tracker, status board, monitoring)

Sunday, October 16, 11

Page 46: Mag rails 2011   web application deployment for small teams

THAT’S A LONG LIST

Sunday, October 16, 11

Page 47: Mag rails 2011   web application deployment for small teams

AND NOBODY DOES EVERYTHING

Sunday, October 16, 11

Page 48: Mag rails 2011   web application deployment for small teams

SO WHERE DO WE BEGIN?

Sunday, October 16, 11

Page 49: Mag rails 2011   web application deployment for small teams

$ CAP PRODUCTION DEPLOY

Sunday, October 16, 11

Page 50: Mag rails 2011   web application deployment for small teams

# > touch /tmp/some-file

$ > touch /tmp/some-file

Sunday, October 16, 11

Page 51: Mag rails 2011   web application deployment for small teams

$ > su someotheruser

$ > su - someotheruser

Sunday, October 16, 11

Page 52: Mag rails 2011   web application deployment for small teams

The Dreyfus Model

Sunday, October 16, 11

Page 53: Mag rails 2011   web application deployment for small teams

UNIX 101

Sunday, October 16, 11

Page 54: Mag rails 2011   web application deployment for small teams

USERS AND GROUPS

Sunday, October 16, 11

Page 55: Mag rails 2011   web application deployment for small teams

$ CAP PRODUCTION PERMISSIONS:FIX

Sunday, October 16, 11

Page 56: Mag rails 2011   web application deployment for small teams

$ CAP PRODUCTION PERMISSIONS:FIX

desc “fix permissions”task :fix, :roles => [:web, :app] do

run “chown nobody:apache /var/www/otb/“run “chmod -R 666 #{current_release}”run “chmod -R 777 #{current_release}/bin/”

end

Sunday, October 16, 11

Page 57: Mag rails 2011   web application deployment for small teams

Sunday, October 16, 11

Page 58: Mag rails 2011   web application deployment for small teams

$ whoami

Sunday, October 16, 11

Page 59: Mag rails 2011   web application deployment for small teams

$ whoami codebeaker

Sunday, October 16, 11

Page 60: Mag rails 2011   web application deployment for small teams

$ whoami codebeaker

$ groups

Sunday, October 16, 11

Page 61: Mag rails 2011   web application deployment for small teams

$ whoami codebeaker

$ groups codebeaker staff deploy sudo

Sunday, October 16, 11

Page 62: Mag rails 2011   web application deployment for small teams

$ whoami codebeaker

$ groups codebeaker staff deploy sudo

$ echo $PATH

Sunday, October 16, 11

Page 63: Mag rails 2011   web application deployment for small teams

$ whoami codebeaker

$ groups codebeaker staff deploy sudo

$ echo $PATH /usr/bin:/bin:/usr/sbin

Sunday, October 16, 11

Page 64: Mag rails 2011   web application deployment for small teams

Sunday, October 16, 11

Page 65: Mag rails 2011   web application deployment for small teams

$ id

Sunday, October 16, 11

Page 66: Mag rails 2011   web application deployment for small teams

$ iduid=501(codebeaker) gid=20(staff) groups=20(staff)12(everyone),33(_appstore),80(admin),204(_developer)

Sunday, October 16, 11

Page 67: Mag rails 2011   web application deployment for small teams

Sunday, October 16, 11

Page 68: Mag rails 2011   web application deployment for small teams

$ id

Sunday, October 16, 11

Page 69: Mag rails 2011   web application deployment for small teams

$ iduid=1000(codebeaker) gid=1000(codebeaker) groups=60(staff)90(deploy),50(sudo)

Sunday, October 16, 11

Page 70: Mag rails 2011   web application deployment for small teams

$ iduid=1000(codebeaker) gid=1000(codebeaker) groups=60(staff)90(deploy),50(sudo)

$ touch example

Sunday, October 16, 11

Page 71: Mag rails 2011   web application deployment for small teams

$ iduid=1000(codebeaker) gid=1000(codebeaker) groups=60(staff)90(deploy),50(sudo)

$ touch example

$ newgrp -l deploy

Sunday, October 16, 11

Page 72: Mag rails 2011   web application deployment for small teams

I/O

Sunday, October 16, 11

Page 73: Mag rails 2011   web application deployment for small teams

PROCESSES

Sunday, October 16, 11

Page 74: Mag rails 2011   web application deployment for small teams

PERMISSIONS

Sunday, October 16, 11

Page 75: Mag rails 2011   web application deployment for small teams

37SIGNALS

Sunday, October 16, 11

Page 76: Mag rails 2011   web application deployment for small teams

SHELLS, LOGIN AND NON-LOGIN

Sunday, October 16, 11

Page 77: Mag rails 2011   web application deployment for small teams

ENVIRONMENTAL VARIABLES

Sunday, October 16, 11

Page 78: Mag rails 2011   web application deployment for small teams

SSH

Sunday, October 16, 11

Page 79: Mag rails 2011   web application deployment for small teams

SOURCES OF TRUTH

Sunday, October 16, 11

Page 80: Mag rails 2011   web application deployment for small teams

DISTRIBUTION OF RESOURCES

Sunday, October 16, 11

Page 81: Mag rails 2011   web application deployment for small teams

HOW?There isn’t any software on the planet for doing this correctly.

Sunday, October 16, 11

Page 82: Mag rails 2011   web application deployment for small teams

HELP ME WRITE IT…

Sunday, October 16, 11

Page 83: Mag rails 2011   web application deployment for small teams

I’M @CODEBEAKERThanks for your time and attention, any questions?

Sunday, October 16, 11