Microservices

with

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

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

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

Business Impact

Types of Development Work

Expected change in Node.js usage

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

Microservices with Node.js

By Kevin C.

Microservices with Node.js

This sharing is an excerpt of the topic about building microservices base from the talks and workshops I attended at Node Summit 2018 @ San Francisco USA. It summarized the technical highlights of industry's best practices for using Node.js to build and trace microservices at scale.

  • 567