38
Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer @avleen With much credit: Daniel Schauenberg: (@mrtazz)

Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

  • Upload
    others

  • View
    4

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

Scaling Continuous Deployment @ Etsy

Avleen Vig

Staff Operations Engineer @avleen With much credit: Daniel Schauenberg: (@mrtazz)

Page 2: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Statistics

Page 3: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Statistics

Page 4: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Our applicationMostly monolithic

Page 5: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Our applicationA few services too

Page 6: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Our applicationDeploy frequency

Page 7: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Our teamBefore..

Page 8: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Our teamToday..

..and that’s just a fraction!

Page 9: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Deploying codeThe push train

Item by decomodwalls

Page 10: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Deploying code#push

• IRC channel to organize push trains

• Join a train if you want to deploy changes

• Schedule is planned via the channel topic

• First in the train is the driver

Page 11: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Deploying code

<prod> kseever* + jameslee | jpaul | avleen (c)

#push

Page 12: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Deploying code

<prod> bateman* + krunal* + enorris* | tristan (c) + jameslee (c) + jlaster (c) | dawa + corey + sandosh + jklein + magera + seth_home + mpascual + nathan | bateman | russp (c)

#push

Page 13: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Deploying codeDeployinator

Page 14: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

https://github.com/etsy/deployinator

Page 15: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Deploying codeSo what’s the problem?

Page 16: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Deploying codeSo what’s the problem?

• Deploy-time requests are not atomic

• Weird limbo while syncing in-place

• Limits on pushes-per-day • Long wait times

Page 17: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Deploying codeUm, limits per day?

!

• (push_queue_hours * 60) minutes to deploy

• At 15 mins/deploy, we get ~32 deploys per day - not enough!

Page 18: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Our options:

• More code in each deploy • Allow concurrent deploys • Reduce deploy times • Make deploys atomic • Fork more concurrent rsyncs

Page 19: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?More code in each deploy:

• Also has limits • How many people can be in each push?

• We found ~8 to be our limit for reducing wait times

Page 20: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Allow concurrent deploys:

!

• For config changes • Code on independent systems • The few services we have

Page 21: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Concurrent deploys:

HELLO SPLIT QUEUESHELLO SPLIT QUEUES

Page 22: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Reduce deploy times:

• Tweaks around rsync • Keep codebase in RAM (tmpfs) • Increase rsync concurrency • Reduce timeouts and retry intervals

Page 23: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Make deploys atomic:

Yin Yang

Active Docroot

Page 24: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Make deploys atomic:

Yin Yang

Active Docroot

rsync

Page 25: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Make deploys atomic:

Yin Yang

Active Docroot

Page 26: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Make deploys atomic:

Yin Yang

Active Docroot

Page 27: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Make deploys atomic:

• Not so trivial • PHP opcache problems • include_path troubles • Swapping symlinks mid-request

Page 28: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

http://github.com/etsy/mod_realdoc

Page 29: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Make deploys atomic, mod_realdoc:

!

• Apache post_read_request hook • Whole request works on realpath of docroot

• Caches realpath for 2s

Page 30: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

http://github.com/etsy/incpath

Page 31: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

How can we scale it?Make deploys atomic, incpath:

!

• PHP extension • Updates a portion of include_path

• $_SERVER[“DOCUMENT_ROOT”]

Page 32: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Infrastructure

Page 33: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Scaling infrastructureBefore:

DeployHostDeployinator Production

Servers

Page 34: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Scaling infrastructureAfter:

DeployHostDeployinator Production

Servers

DeployHost

Page 35: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Results!

Page 36: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Results!What did we gain?

!

• No need to restart apache • Entire deploy in one push • Opcode cache stays warm!

Page 37: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Results!Push frequency

!

• (push_queue_hours * 60) minutes to deploy

• Still ~15mins/deploy: Much more code going out Tests still run fast Less time waiting to deploy

Page 38: Scaling Continuous Deployment @ Etsy - QCon London€¦ · Scaling Continuous Deployment @ Etsy Avleen Vig Staff Operations Engineer ... Scaling infrastructure After: Deploy Host

@avleen

Q&A