Takeaways from

Kevin C Chen @ Product Improve Operations

Source: https://twitter.com/nodesummit

WHY?

  • A platform to get insights from large enterprise companies for how they adopt Node.js in their existing tech stack
     
  • Understand how companies are using Node.js to build microservices
     
  • Learn best practices and tools used by the Node.js community
     
  • Be in the shoe of our customer

Day Zero Sessions

2 Days Conference

2 Days Workshop

45 Talks

~15 Sponsor Booths

Speakers from Node.js Core Team, Google, Netflix, TELUS, CBC, Eventbrite, Slack...etc

Agenda

  • Enterprise / Cloud
  • Community
  • Security
  • Microservices deployment with Kubernetes
  • Observability ecosystem
    • Performance, tracing
  • Node.js ecosystem
    • Electron
    • AI
    • React Native
    • GraphQL with React
  • What's next?

Relevance - Where do we use Node.js?

  • DSAAS - for fast heart-beat feature since 3 years ago
     
  • Development
    • npm / yarn dependency management
    • Backend of frontend - mock API servers in dev mode
       
  • Testing
    • JavaScript unit test/SDK API Automation test runner - Jest
    • Smart Check UI Test Automation with Cypress
    • Use Node that generates agent like traffic for scalability testing
    • Postman REST API Test Automation
    • Lighthouse - UI auditing tool to measure performance / accessibility...etc
       
  • Our DevOps journey: monolith => microservice mode

Using Node.js in Eeveryday Desktop App

Reference: https://insights.stackoverflow.com/survey/2018

Reference: https://insights.stackoverflow.com/survey/2018

Source: http://www.modulecounts.com/

More than 530 new packages are published to npm everyday

Fastest growing open source platform in the world

What you will learn today

  • Node.js basic
     
  • Example of how JavaScript SDK is distributed - Paypal
     
  • Microservice with Node.js - Why & How - DevSecOps
     
  • How to trace / measure the operation of microservices

POLLS

Source: http://i.huffpost.com/gen/1311474/images/o-SCHOOLS-facebook.jpg

What is Node.js?

  • Node.js is an open source JavaScript runtime built on Chrome's V8 JavaScript engine

Outside of browser

Customer's Order - Request

Waiter - Thread

Chef - I/O

1. "One salad please"

2. "Sure, one moment please..."

3. "Ok, working on it..."

4. "But I also need a cup of water..."

5. "..."

1. "One salad please"

2. "Sure, one moment please"

3. "Ok, working on it..."

4. "But I also need a cup of water..."

5. "Sure, right away..."

7. "Combo #2 please"

6. "Won't be long..."

8. "Absolutely!"

10. "Water is ready"

12. "Salad is ready"

14. "Combo #2 is ready"

13. "Enjoy the meal"

9. "Ok, working on it..."

15. "Enjoy the meal"

11. "Here is the water"

Node.js is great for?

  • Designed to build scalable network applications
     
  • Can make calls to multiple APIs in parallel
  • Suited for the foundation of a web library or framework

Where Node is deployed

Who uses it?

Reference: https://developer.paypal.com/docs/checkout/

Distributing SDK?

Compile and bundle
everything

NPM

CDN

Challenges

  • NPM
    • Constantly adding new features, SDK has many minor versions, becomes tricky when you have SDKs rendering UI
       
  • CDN
    • ​Versioned URL or "evergreen" URL serves static script
      <script src="paypalobjects.com/checkout.js"/>

       

    • Keeping backwards compatibility is painful, resulting scripts balloons in size over time

3.1.1

3.1.2

3.1.3

3.1.4

PayPal's New Solution

<script src="paypal.com/js/v4
    ?components=buttons,hosted-fields
    &client-id=xyz
    &locale=fr_FR"/>
  • No pre-bundled script
  • Bundled on-demand on server-side
  • Cached on edge servers
  • URL params dictates which feature (component) are shipped
  • Each client received the customized code they need
/JS/V4

NEEDED
FEATURE

NEEDED
L10N

LAZY LOADED CODE

EMBEDDED GRAPHQL DATA

GRAPHQL
CONFIG
SERVICE

GRAPHQL
PAYMENTS
SERVICE

GRAPHQL
FUNDING ELIGIBILITY
SERVICE

GRAPHQL
L10N
SERVICE

Before

Engineering

Pre-Bundle Build

NPM

CDN

After

Engineering

Edge

NPM

/JS/V4

Microservices

with

Node.js

Source: http://turnoff.us/geek/microservices/

What is microservices?

  • A typical microservice addresses only one fairly narrow business goal or need
     
  • Functionally quite simple: an incoming request is processed, and a response is generated accordingly
     
  • Services are distributed and communicate with one another via http / message bus in service mesh
     
  • Designed to fail gracefully, without taking down adjacent services

Why use microservices?

Services can be developed with the technology that does a given task best

Can be portable and scale independently

Dev teams stay small and agile

Continuous developed and deployed by independent teams

Why Node.js?

  • Suitable for consuming data from different sources / data streams and transforming it for other applications
     
  • Widely used to consume and provide APIs (e.g. REST, GraphQL)
     
  • Event-based Node.js allows application to load off asynchronous tasks to
     
  • Fast, lightweight with high throughput

Ref: CLOUD NATIVE NODE.JS @ 2018 Node Summit by Chris Bailey, Chief Architect, Cloud Native Runtimes, IBM

Let's build an online reservation system

Architecture Workshop - nearForm 2018

Source: nearForm NodeSummit 2018 - Architecture Workshop

Requirements

  • Limited camping site
  • Seasonal - open between 6/1 ~ 8/31
  • Must be reserved 3 months in advance for duration less than 7 days
  • Must be reserved 4 months in advance for duration at least 7 days
  • First come, first serve basis
  • Collecting deposit to hold the reservation
  • Allowing user to return later to complete full payment, modify, or cancel the reservation
  • Must be able to handle the load & process all reservation requests

MVP
(Minimum Viable Platform)

MVP Requirements

  • Register and login
  • 1 booking per user.
    • While one site is being reserved by one user, it is unavailable to other users
  • Account for booking limitations

Websockets

Source: nearForm NodeSummit 2018 - Architecture Workshop

Source: nearForm NodeSummit 2018 - Architecture Workshop

MVP Solution - Issues

  • Mini-monolith
    • React web app is served directly from Node.js causing the eventloop to
      slow down http response time
       
    • Every web socket is handled by each single Node.js app
       
    • Single DB connection per Node.js process
       
  • No back-pressure handling in case of high volume
     
  • Authentication needs to be carried across services
     
  • This solution scales linearly with traffic (250 instances to serve 250
    requests) without blocking!

Let's Improve

  • Optimize authorization across services
     
  • Solution must scale cost-effectively for peak traffic (10k req/sec)
     
  • Solution must implement techniques to help scaling horizontally
     
  • Implement circuit breaking and back-pressure management

Source: nearForm NodeSummit 2018 - Architecture Workshop

Let's make it better

  • Scale authentication up to 10k req/sec
     
  • Segregation of concerns
     
  • What if I want to continue my payment later on?

Source: nearForm NodeSummit 2018 - Architecture Workshop

What if anything goes wrong?

  • Application level monitoring
     
  • Infrastructure level monitoring and alerting
     
  • Auditing capability
     
  • Request tracking

Source: nearForm NodeSummit 2018 - Architecture Workshop

Source: nearForm NodeSummit 2018 - Architecture Workshop

DevSecOps

The Evolution

Databases

App Servers

R-Proxy

Web Page

Diagnostic
Package

The Evolution - Go to Cloud

The Evolution - The DevOp way

Centralized Logging
System

The Evolution - microservices

BFF

BFF

Auth

Content

i18n

Config

CDN

Postgres

Redis

S3

Source: http://turnoff.us/geek/are-you-ready-for-microservices/

Observability?

  • Where is the problem?
     
  • Need a way to drill down to the precise part of a service transaction where failures or latency are occurring

MTTD

MTTR

DevOps Goals

Is it fixed yet?

Source: https://www.slideshare.net/EduardoSolis4/opentracing-meetup-austin-tx

  • Custom logging from each service / platform?
    • Telemetry data with tags
    • Req/Res logs (JSON/XML)
    • Application log (log4j)
    • Metrics
       
  • x-requestmarker=abc1234​
    

     

  • Trace between dependencies?
  • Async Operations?

Distributed Tracing

  • A trace tells the story of a transaction or workflow as it propagates through a distributed system.
     
  • Spans are logical units of work in a distributed system
     
  • Relationships are the connections between Spans.

Distributed Tracing

Image Source: https://expediadotcom.github.io/haystack/docs/ui.html

Summary

  • Our current usage of Node
     
  • Basic of Node.js & Asynchronous programming model
     
  • Example of how JavaScript SDK is distributed - Paypal
     
  • How it could be used with other technologies to build microservices
     
  • Tools and skills to help you trace / measure the operation of microservices

Appendicies

Why Node.js?

  • Highly active community and ecosystem
     
  • Constant flow of new features and software being built around and for Node.js​
     
  • Community-built tools, tutorials, and documentation all help to ensure that anyone developing with Node.js can find helpful solutions to common problems
     
  • Knowledge of JavaScript can be applied in both backend and frontend

Why Node.js?

By building on Node’s actively-developed, open-source system, we get the benefit
of lots of people making the software better without us doing anything. We can
sort of sit back and it just gets better on its own, which is pretty great.


---- Matt Ranney, Senior Staff Engineer, Uber

Ref: The State of Node for the Enterprise Report, 2018 Edition --NODESOURCE

Gain better insight on Node

  • Suite of tools to help diagnose and pinpoint your Node.js performance issues with recommendations
     
  • Leverage metric collected from load testing and expose bottlenecks
     
  • Measure asynchronous activity in a decoupled way

Demo

Source: https://clinicjs.org/logos/hero.png

Interesting Data

A recent Node.js Foundation survey found that 45% of developers surveyed use Node.js with containers.

Business Impact

Types of Development Work

Expected change in Node.js usage

Made with Slides.com