applied lean startup ideas: continuous deployment at kaching

44
Continuous Deployment at kaChing Applied Lean Startup Ideas: #leanstartup &

Upload: pascal-louis-perez

Post on 13-Jan-2015

10.480 views

Category:

Technology


2 download

DESCRIPTION

kaChing is an online platform that connects investors with outstanding investment managers. We are a technology driven company, which has adopted lean methodologies from the start, and has achieved a 5-minute commit-to-production cycle. Continuous deployment is a way of life and is integral to our engineering culture. In this talk, we will present our system's architecture and discuss our service oriented platform dubbed kawala (in the process of being open sourced on http://code.google.com/p/kawala). We will describe the mechanics of an automated release from check-in to production: clean build with full regression testing in less than 3 minutes, packaging and deployment by automatically redirecting traffic using ZooKeeper for coordination, health checks and immune system to monitor the release. Finally, we will talk about planned evolutions and the next challenges we face in our infrastructure.

TRANSCRIPT

Page 1: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Continuous Deployment at kaChingApplied Lean Startup Ideas:

#leanstartup

&

Page 2: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Twenty Deployments a Day Keeps the Nasty Bugs Away

10-May

11-May

12-May

13-May

14-May

15-May

16-May

17-May

18-May

19-May

20-May

21-May

0

5

10

15

20

25

30

Page 3: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

“Connect investors with outstandinginvestment managers”

Page 4: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Release is a Marketing Concern

Reducing Code Inventory is what Engineering Focuses On

Page 5: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Lean Startup at kaChing

• Methodical approach to eliminating waste• No Quality Assurance engineers, no Operations

team• Empower everybody to drive their own projects

“Human institution designed to create something new under conditions of extreme uncertainty” – Eric Ries

Page 6: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

What is Continuous Deployment?

• Continuous, successful and repeatable methodology to deploying code

• Automates every steps of taking checked in code and making it run on production servers, in front of customers

Page 7: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

True Story

• Investment managers calls, comments about unintuitive trading flow.

• Improvements are made, and deployed within the next 20 minutes.

• We call him back “What do you think of the improvement?”

Page 8: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Benefits of Continuous Deployment

• It allows quick iterations• Obsoletes processes, e.g. “cutting a release”• Reduces risk• Everyone is aware of production• No one throws code over the wall• Exposes 24x7 operational requirements• Trunk stable

Page 9: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

ContinuousDeployment

Immune System

Making Continuous Deployment a Reality

Test Driven Development

Culture

Page 10: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

#architecture

Page 11: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Our architecture

• Service oriented system• Vertical sharding• Everything uses the same platform kawala• Coordination using ZooKeeper• Data interchange using JSON and Protobufs

Page 12: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Typical Stack

• Clustered services, multiple instances• Replicated databases (e.g. MySQL or NoSQL)• Caching (e.g. memcached)• Denormalized data (e.g. Voldemort)

Page 13: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

kawala

• Command pattern. A command is a query• Dynamic Inversion of Control• Queries produce a value

Page 14: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Sample Query

class GetUser(Id<User> userId) { @Inject UserRepository repository; public User process() { return repository.load(userId); }}

Page 15: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

What We do with Queries

RPC Persist Queries

Push into MQ

Command Line Tools

CPS Render Pages

Serve BLOBS

Page 16: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Lifecycle

• 1. Commit• 2. Testing• 3. Deployment• 4. Production Validation• 5. Lifetime Monitoring

Page 17: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Development

• Trunk stable• Small, frequent commits• Unreleased features live behind experiments• Forward & Backward compatibility• Responsive code review• Pair difficult problems• Trivial rollbacks

Page 18: Applied Lean Startup Ideas: Continuous Deployment at kaChing

#testing

Page 19: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Testing Philosophy

• Only automated testing matters• If it isn’t tested, it isn’t finished or correct• Write testable code• Embrace abstractions• Testing is cross functional, we all own quality

Page 20: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Benefits of TDD

• It allows quick iterations• It empowers engineers to change anything,

and as such helps in scaling the team• It is more cost effective than debugging• It obsoletes the need for functional QA• It facilitates continuous refactoring, allowing

the code to get better with age• It attracts the right kind of engineers

Page 21: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Types of Testing

• Unit Testing - does the code work?• Integration Testing - does the code work

together?• Regression Testing - learn from your

mistakes• Frontend Testing - a whole different

ballgame

Page 22: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Defensive Testing

• Nightmare scenarios• A common conversation at lunch:– Alice: What would happen if X blew up?– Bob: uh... the site would go down.

• Fix it, test for it

Page 23: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Implementation

• Frameworks: junit, dbunit• CI: Hudson• Frontend: Selenium

Page 24: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Production

• Process, Infrastructure, Deployment, Monitoring

Page 25: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Process

• Everyone: writes code and tests, releases to production, adds monitoring– Specialists help out when needed

• New hires push code the first day• Problems, issues, errors, bugs, oversights...

Page 26: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Stability

• Cluster everything• As little global state as possible• Maintain global state through ZooKeeper• Monitor everything

Page 27: Applied Lean Startup Ideas: Continuous Deployment at kaChing

ZooKeeper

• Reliable Distributed Synchronization• For:– Service Discovery– Service Status– Coarse locking

Page 28: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Life of a Deployment

DM

ZK

PMPM PM

Page 29: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Life of a Deployment

DM

ZK

PMPM PM

Page 30: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Life of a Deployment

DM

ZK

PMPM

Page 31: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Life of a Deployment

DM

ZK

PMPMPM

Page 32: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Life of a Deployment

DM

ZK

PMPMPM

Page 33: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Deployment

• Exponentially increasing group sizes• Increased monitoring during deployment• Self Test• Automated rollbacks

Page 34: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Implementation

• Building: ant• Deploying: rpm, yum• Monitoring: nagios, jcollectd, RRDtool, jmx• Custom automation

Page 35: Applied Lean Startup Ideas: Continuous Deployment at kaChing
Page 36: Applied Lean Startup Ideas: Continuous Deployment at kaChing

#monitoring

Page 37: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Monitoring Philosophy

• Prefer business metrics• Monitor statistical deviations not absolute

values• Automatically annotate graphs

Page 38: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Monitoring Errors

• False negatives - errors of omission• False positives - errors of implementation

Page 39: Applied Lean Startup Ideas: Continuous Deployment at kaChing

End to End Monitoring

• Run Selenium on production• Accessibility, Speed• Ad-hoc Keynote - customized for our flows• Must control data creation, analytics impact

Page 40: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

#future-developments

Page 41: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Quarantining

• Isolate new releases• Flexible partitioning of requests• Gradually shift load to fresh services

Page 42: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

Describing Infrastructure

• Many moving parts– nagios, collectd, backups, services, databases, …

• Consistency is key• Adding new tools should be easy and

thorough• Standardize best practices

Page 43: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

What we Covered Today

• Lean Startup and Continuous Deployment• Anatomy of a Release– Commit, Testing, Deployment, Monitoring

• Future Developments– Quarantining, DSL for Infrastructure

Page 44: Applied Lean Startup Ideas: Continuous Deployment at kaChing

Pascal-Louis Perez, kaChing Group Inc.

References• We’re Recruiting [email protected]• kaChing’s blog http://eng.kaching.com• kawala http://bit.ly/kawala• Deployment Infrastructure

http://eng.kaching.com/2010/05/deployment-infrastructure-for.html

• Extreme Testing http://bit.ly/9bOFaA• Writing Testable Code

http://googletesting.blogspot.com/2008/08/by-miko-hevery-so-you-decided-to.html

• ZooKeeper http://bit.ly/kc-zookeeper• Eric Ries http://startuplessonslearned.com