paasta: running applications at yelp

46
Nathan Handler [email protected] / @nathanhandler PaaSTA Running Applications at Yelp

Upload: nathan-handler

Post on 12-Apr-2017

430 views

Category:

Software


0 download

TRANSCRIPT

Page 1: PaaSTA: Running applications at Yelp

Nathan [email protected] / @nathanhandler

PaaSTARunning Applications at Yelp

Page 2: PaaSTA: Running applications at Yelp

● Nathan Handler / @nathanhandler● Site Reliability Engineer at Yelp● Ubuntu/Debian Developer and freenode staff● PaaSTA Developer

Who am I?

2

Page 3: PaaSTA: Running applications at Yelp

Yelp’s MissionConnecting people with great

local businesses.

3

Page 4: PaaSTA: Running applications at Yelp

Yelp StatsAs of Q1 2016

90M 3270%102M

4

Page 5: PaaSTA: Running applications at Yelp

● Monolithic Python application (~3M LoC)● Builds/deployments took a long time

○ Bottleneck on how often we can deploy● Mistakes are painful

○ Large impact○ Difficult to find○ Slow to fix

History

5

Page 6: PaaSTA: Running applications at Yelp

● Split features into different applications● Smaller services allowed for faster pushes● Easier to reason about issues● Able to scale services independently

Service Oriented Architecture v1

6

Page 7: PaaSTA: Running applications at Yelp

● Standalone application● Stateless● Separate git repository● Typically at Yelp:

○ HTTP API○ Python, Pyramid, uWSGI○ virtualenv

What is a service?

7

Page 8: PaaSTA: Running applications at Yelp

● Statically defined list of hosts to deploy a service on● Operations decides which hosts to deploy to● Monitoring manually configured in Nagios● Manual deployment system via rsync

Deploying Services v1

8

Page 9: PaaSTA: Running applications at Yelp

3x

2x

Does Not Scale

9

1x

Page 10: PaaSTA: Running applications at Yelp

3x

2x

Does Not Scale

10

1x

Page 11: PaaSTA: Running applications at Yelp

● Yelp's Platform as a Service● Builds, Deploys, Connects, and Monitors services● Glue around existing and established open source

tools

PaaSTA

11https://github.com/yelp/paasta#paasta on irc.freenode.net

Page 12: PaaSTA: Running applications at Yelp

12

Page 13: PaaSTA: Running applications at Yelp

PaaSTA Components

13

DockerRegistry

Developer

git push

git pull

git push

docker push

13

Marathon

Sensu

Page 14: PaaSTA: Running applications at Yelp

PaaSTA Components

14

Developer

git push

14

Page 15: PaaSTA: Running applications at Yelp

.├── Dockerfile├── htdocs│ ├── index.php│ └── status└── Makefile

15

A simple service

Page 16: PaaSTA: Running applications at Yelp

DOCKER_TAG ?= $(USER)-dev

test: @echo 'Unit testing'

itest: cook-image paasta local-run --healthcheck --service devops

cook-image: docker build -t $(DOCKER_TAG) .

16

$ cat Makefile

Page 17: PaaSTA: Running applications at Yelp

DOCKER_TAG ?= $(USER)-dev

test: @echo 'Unit testing'

itest: cook-image paasta local-run --healthcheck --service devops

cook-image: docker build -t $(DOCKER_TAG) .

17

$ cat Makefile

Page 18: PaaSTA: Running applications at Yelp

• Containers: like lightweight VMs• Provides a language (Dockerfile) for describing

container image• Reproducible builds (mostly)• Provides software flexibility

18

Docker

docker.com

Page 19: PaaSTA: Running applications at Yelp

FROM ubuntu:xenialMAINTAINER Nathan Handler <[email protected]>

RUN apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y install \ apache2 \ libapache2-mod-php

ENV APACHE_RUN_USER www-dataENV APACHE_RUN_GROUP www-dataENV APACHE_LOG_DIR /var/log/apache2ENV APACHE_LOCK_DIR /var/lock/apache2ENV APACHE_PID_FILE /var/run/apache2.pid

RUN rm -f /var/www/html/index.htmlCOPY htdocs /var/www/html/

CMD ["/usr/sbin/apache2", "-D", "FOREGROUND", "-C", "listen 8888"]EXPOSE 8888 19

$ cat Dockerfile

Page 20: PaaSTA: Running applications at Yelp

✓ yelpsoa-config directory for devops found in /nail/etc/services✓ deploy.yaml exists for a Jenkins pipeline✗ No 'security-check' entry was found in your deploy.yaml.Please add a security-check entry *AFTER* the itest entry in deploy.yamlso your docker image can be checked against known security vulnerabilities.More info: http://servicedocs.yelpcorp.com/docs/paasta_tools/cli/security_check.html✗ No 'performance-check' entry was found in your deploy.yaml.Please add a performance-check entry *AFTER* the security-check entry in deploy.yamlso your docker image can be checked for performance regressions.More info: http://servicedocs.yelpcorp.com/docs/paasta_tools/cli/performance_check.html✓ Jenkins build pipeline found✓ Git repo found in the expected location.✓ Found Dockerfile✓ A Makefile is present✓ The Makefile contains a tab character✓ The Makefile contains a docker tag✓ The Makefile responds to `make cook-image`✓ The Makefile responds to `make itest`✓ The Makefile responds to `make test`✓ Found marathon.yaml file.✓ All entries in deploy.yaml correspond to a marathon or chronos entry✓ All marathon instances have a corresponding deploy.yaml entry✓ monitoring.yaml found for Sensu monitoring✓ Your service uses Sensu and team 'nhandler' will get alerts.✓ Found smartstack.yaml file✓ Instance 'demo' of your service is using smartstack port 20973 and will be automatically load balanced✓ Successfully validated schema: marathon-nova-devc.yaml 20

$ paasta check

Page 21: PaaSTA: Running applications at Yelp

PaaSTA Components

21

Developer

git push

git pull

21

Page 22: PaaSTA: Running applications at Yelp

PaaSTA Components

22

DockerRegistry

Developer

git push

git pull

git push

docker push

22

Page 23: PaaSTA: Running applications at Yelp

---pipeline:- instancename: itest- instancename: push-to-registry- instancename: dev.everything

23

$ cat deploy.yaml

Page 24: PaaSTA: Running applications at Yelp

Jenkins Pipeline

24

Page 25: PaaSTA: Running applications at Yelp

paasta-nova-devc.demo-20160503T231914-deploypaasta-nova-devc.demo-20160503T234021-stoppaasta-nova-devc.demo-20160503T234202-start

25

$ git tag

Page 26: PaaSTA: Running applications at Yelp

• Describe end goal, not path• Helps us achieve fault tolerance.

"Deploy 6de16ff2 to prod"vs.

"Commit 6de16ff2 should be running in prod"

Gas pedal vs. Cruise Control26

Declarative control

Page 27: PaaSTA: Running applications at Yelp

Description: A demo PaaSTA service for OSCON 2016External Link: http://conferences.oreilly.com/oscon/open-source-us/public/schedule/detail/49358Monitored By: team nhandlerRunbook: Please set a `runbook` field in your monitoring.yaml. Like "y/rb-mesos". Docs: https://trac.yelpcorp.com/wiki/HowToService/Monitoring/monitoring.yamlGit Repo: [email protected]:services/devopsJenkins Pipeline: https://jenkins.yelpcorp.com/view/services-devopsDeployed to the following clusters: - nova-devc (N/A)Smartstack endpoint(s): - http://169.254.255.254:20973 (demo)Dashboard(s): - https://uchiwa.yelpcorp.com/#/events?q=devops (Sensu Alerts)

27

$ paasta info

Page 28: PaaSTA: Running applications at Yelp

PaaSTA Components

28

DockerRegistry

Developer

git push

git pull

git push

docker push

28

Marathon

Page 29: PaaSTA: Running applications at Yelp

• Mesos is an "SDK for distributed systems", not batteries-included.

• Requires a framework• Marathon• Chronos for scheduled batches

• Can run many frameworks on the same cluster• Supports Docker as task executor

29

mesosphere.iomesos.apache.org

Scheduling: Mesos + Marathon

Page 30: PaaSTA: Running applications at Yelp

---demo: cpus: 0.1 instances: 3 mem: 500 monitoring: alert_after: 0m bounce_method: brutal deploy_group: dev.everything

30

$ cat marathon-nova-devc.yaml

Page 31: PaaSTA: Running applications at Yelp

PaaSTA Components

31

DockerRegistry

Developer

git push

git pull

git push

docker push

31

Marathon

Page 32: PaaSTA: Running applications at Yelp

● Brutal: Stops old versions and starts the new version, without regard to safety.

● Upthendown: Brings up the new version of the service and waits until all instances are healthy before stopping the old versions.

● Downthenup: Stops any old versions and waits for them to die before starting the new version.

● Crossover: Starts the new version, and gradually kills instances of the old versions as new instances become healthy.

Bounce Strategies

32

Page 33: PaaSTA: Running applications at Yelp

33

Page 34: PaaSTA: Running applications at Yelp

34

Page 35: PaaSTA: Running applications at Yelp

35

Page 36: PaaSTA: Running applications at Yelp

36

Discovery in PaaSTA: Smartstack

mesosslave

box2client

nerve

HAProxy

synapse

box1service

nerve

mesosslave

synapse

HAProxy

ZooKeeperMetadataHTTP request

healthcheck

Page 37: PaaSTA: Running applications at Yelp

37

Latency Zones

SuperregionRegionHabitat

Page 38: PaaSTA: Running applications at Yelp

---demo: advertise: [region] discover: region proxy_port: 20973

38

$ cat smartstack.yaml

Page 39: PaaSTA: Running applications at Yelp

Pipeline: https://jenkins.yelpcorp.com/view/services-devops

cluster: nova-devc instance: demo Git sha: 6de16ff2 State: Running - Desired state: Started Marathon: Healthy - up with (3/3) instances. Status: Running. Mesos: Healthy - (3/3) tasks in the TASK_RUNNING state. Smartstack: Name LastCheck LastChange Status useast1-devc - Healthy - in haproxy with (3/3) total backends UP in this namespace.

39

$ paasta status

Page 40: PaaSTA: Running applications at Yelp

Cluster: mesosstageDashboards: Marathon RO: http://marathon.paasta-mesosstage.yelp/ Smartstack: http://paasta-mesosstage.yelp:3212 Chronos RO: http://chronos.paasta-mesosstage.yelp/ Mesos: http://mesos.paasta-mesosstage.yelpMesos Status: OK quorum: masters: 3 configured quorum: 2 frameworks: framework: chronos-2.4.0 count: 1 framework: marathon count: 1 CPUs: 1.00 / 7 in use (14.29%) Memory: 3.03 / 42.85GB in use (7.07%) Disk: 10.00 / 153.81GB in use (6.50%) tasks: running: 9 staging: 1 starting: 0 slaves: active: 7 inactive: 0Marathon Status: OK marathon apps: 5 marathon tasks: 9 marathon deployments: 0Chronos Status: OK Enabled chronos jobs: 1 40

$ paasta metastatus

Page 41: PaaSTA: Running applications at Yelp

PaaSTA Components

41

DockerRegistry

Developer

git push

git pull

git push

docker push

41

Marathon

Sensu

Page 42: PaaSTA: Running applications at Yelp

---team: nhandlerpage: truenotification_email: [email protected]

42

$ cat monitoring.yaml

Page 43: PaaSTA: Running applications at Yelp

43

Page 44: PaaSTA: Running applications at Yelp

PaaSTA Components

44

DockerRegistry

Developer

git push

git pull

git push

docker push

44

Marathon

Sensu

Page 45: PaaSTA: Running applications at Yelp

Autoscaling

45

Page 46: PaaSTA: Running applications at Yelp

@YelpEngineering

fb.com/YelpEngineers

engineeringblog.yelp.com

github.com/yelp46