DevCon-Shikhar Slides

Preview:

Citation preview

Deploying Node applications at scale

Shikhar Kapoor (@kapoorshikhar)

UI Engineer @ Flipkart

A modern front-end engineers job

Webpack

React

Redux

GulpNodeAngular

Express

GraphQL

NPMMongoDB

Grunt

Jest

Mocha

• Branching Strategies

• Continuous Integration

• Accelerating build times

• Packaging

• Deployments

• Monitoring

• Testing

Branching strategies

• Decide upfront and enforce them.

• Master is sacred!

• Feature flags are your friends.

Mainline/Master

Future

Feature1

Feature2

Feature3

Long release cycles

Shorter but fixed release cyclesMainline/Master

Release - week 1

Fix

Feature

Fix

Release - week 2

Feature

Feature

Fix

Short cycles/ Daily deploymentsMainline/Master

Fix

Feature 1 *

Fix

Feature1 *

Feature 2 *

Feature 2 *

* Features get pushed to master daily, with feature flags

Continuous Integration

• Tools

• Automate mundane tasks like linting, unit test ..

• Build on merge

• Store artifacts

Pull request

Run tests

Tests passing?

Merge/Rebase

Build

FixNo

Yes

Accelerate build times

• Build once, promote everywhere

• BUT be careful of the gotchas

• Freeze dependencies (Yarn, Shrinkwrap)

• Offload mundane tasks to orchestrators

Get playbook Get hosts

Start

Run tasks

EndA typical orchestration workflow

Packaging

• How do you package and send your code to the server?

• Git clone

• Archive and copy

• Debian (FPM, Post Install, Versioning, easy reverts)

Deployment

• Manage your environments, keep them as similar to production as possible.

• Blue-Green? Rolling?

• Keep your deployment scripts close and your rollback scripts closer!

Production Cluster

Blue green deployment strategy

Stage Cluster

Load Balancer

Production Cluster

Load Balancer

Rolling deployment strategy

Load balancer

Monitoring• What should you monitor?

• Trends

• Stack traces/ deep dives

• How do you monitor?

• OpenTSDB based tools like Grafana for trends

• Sentry/ NewRelic for deep dives and stack traces

Image: http://grafana.org

Testing• What to test?

• Functional - Automate critical flows.

• Unit tests

• Non-functional

• Capacity testing and API Fanout

• Performance

• RUM / Synthetic - SpeedCurve, Dareboost

Key takeaways

Thank you!@kapoorshikhar