FullStack DevOps

 

https://slides.com/alexfernandez/2016-07-fullstack-devops/

Your Host Tonight


@pinchito
Alex Fernández
Senior Developer at MediaSmart Mobile
Organizer at MadridJS, Node.js Madrid, JSDayES

What We Will See


What Is DevOps?


DevOps in JavaScript


Some Case Studies


Build Or Not?


Conclusions

What Is DevOps?


  

FullStack? Development, 2016

Frontend: JavaScript

Backend: JavaScript

DevOps: ???

So What Is DevOps?


Amateurs talk about tactics,

but professionals study logistics.

Gen. Robert H. Barrow, USMC

noted in 1980.


Paraphrasing:

Amateurs worry about programming,

while professionals care about deployment.


Continuous Deployment


Probably the most important practice in DevOps


Continuous Integration: tested on integration env


Continuous Delivery: tested on several envs


Continuous Deployment: go all the way and deploy!


Use dark launches, feature flags, canary deployments

What Else?


Build

Testing

Logging

Alerting

Monitoring

Provisioning

Orchestration

Balancing

So, Just a Sysadmin? Not So Fast


Development team deploys,

monitors and orchestrates…


writing code, of course!


Everything is automated

DevOps in JavaScript

Guess the DevOps Package!


Java

Ruby

Python

Golang

C

But Node.js is Perfect for DevOps!


Integrate several APIs


Asynchronous code


Concurrent requests


Libraries for everything


Succint code

Stop! Demo Time

Automate Your Cloud


Official AWS API:

npm install aws-sdk 


Official Azure API:

npm install azure 


Official Google Cloud API:

npm install gcloud 

(requires C library) (sucks)

Example: Build an Orchestrator


Use "Native" Mechanisms


Run servers using Upstart or Systemd


Run periodic tasks using crontab


Use Bash wherever possible


Connect using SSH

Some Case Studies


MediaSmart Mobile


We serve mobile advertising


Match bid offers with campaigns


Real time bidding (OpenRTB)


Make bid and compose ad


In near real time (~80 ms)

Guilty!



We help keep the app ecosystem alive

Some Numbers


50+ countries


Peaks of 325 krps


Average of 200 krps


20 billion requests per day


34 million daily impressions

Deployment Infrastructure


A simple bash script to start


Built for (and with) Node.js packages


Held together with some custom Node.js scripts


Recently migrated to StriderCD


Now with a Graphical Interface!

StriderCD In Action


Nginx Balancer


Previously using Amazon's Elastic Load Balancer


Eating up to 20% of our monthly bill


Replaced by an Nginx balancer


DNS balancer in Node.js


Custom Lua logging

Nginx Monitoring


Custom Node.js script


Reads stats every minute


Aggregates stats in CloudWatch


Runs using crontab


Can kill instances not responding

Traffic Dashboard

Clever Proxy


Filter out 90% of traffic
Decides which requests are less attractive


Written in Erlang (!)


Saved about 80% of costs

Holds the grunt of the 300 krps
with about 10 servers

It's an operational miracle

Filter CPU Load


Pricing Server


Decides the price to pay for each bid

Intensive computations


Predictive algorithm:

estimates CTR of bid offer


Written in Go (!!)


Handles queries in ~500 µs (2 ms)

The Limits of JavaScript


The Limits of JavaScript (Realistic)

The Limits of JavaScript (Fearful)

Server Automation


Distribute a command to a set of servers


Custom scripts using AWS libraries


Our next adventure:

migrate to ShipIt

another npm package

Build

Or Not

Do not Be Afraid to Build



Just going to give you emotional arguments


Do not expect answers! Not from me


At most, some uncomfortable questions 


Companion article:

https://alexfernandez.github.io/2016/build-or-not.html

The Joy of Building Things


People build things because they love to


Starting a green field project can be exhilarating


Helps attract and keep elusive talent


Someone had to build first!

Why let them have all the fun?

NIH Syndrome


"Not Invented Here":

Distrust products offered by third parties


Joel Spolsky:

If it is a core business function

do it yourself, no matter what.


As easy as identifying core business functions

Right?

Core Business Functions


Banks: outsourcing IT


Google: self-driving cars


Facebook: providing Internet access


Apple: music distribution, watches

Reinventing the Wheel


Does the world really need a new testing library?


I don't know or care


If I need it, I will surely build it

$7600 Tesla Wheels

Learning, the Easy Way


The best way to learn is by building


DevOps is not just installing a package


Make infrastructure a first-class citizen


Installing a package can be simple if you know how


The best way to learn infrastructure is by building it

Against Craftmanship


Software devs are artisans practicing their craft


Artisans may get carried away

and build too much


Use modules as standard parts


Maintaining software can be hard

and expensive

Open Source Software


Middle ground between building and installing


Software as a community


Build custom extensions

and share them!


E.g.: send diffs by email

using StriderCD

Joining the Pieces


Combine several packages into a larger entity


Continuous deployment requires:

  • code repos
  • test library
  • notification tools
  • distributed deployment


May require glue code

So, Should I Build or Not?


There is not a universal path for all destinations


Consider:

  • Are you building a state-of-the-art project?
  • Which options is more cost-effective?
  • Which option is more likely to succeed?
  • What is the cost of switching?
  • Which option is more fun?

Conclusions


DevOps Is Cool


Not just install a Jenkins instance somewhere


Merge development and sysadmining


Write code to do fun stuff


Build upon your work

We Need More JavaScript DevOps!


Node.js is perfect!


In-browser is also cool


Emerging Node.js packages


Watch operational constraints

Build or Not?



If it gives you a competitive advantage

build it yourself, no matter what.


Thanks!


@pinchito