You are on page 1of 6

Microservices are the most important part of JAMstack, the A

stands for API, is the only feature with which a static site can keep
it’s fast, secure, robust ness, having a dynamic behavior.

When I started my career in OpenSource, I learnt a thing, the


presentation layer is all about making a static HTML to dynamic
one. This was a flaw in the Monolithic architecture. The site being
extreme dynamic (even to maintainers), extreme secure, it lacks
something. Being a site owner, it becomes more pathetic, spending
a huge piece from earning and investing that for support and
upgradation, the sites are being hacked, not fast enough, the
configuration drift continues, resulting catastrophe and entropy.

We all know, thanks to JAMstack, that even my static site, can


connect to an external API, for dynamic data. Now when it the
discussion about API, it can be a microservice, runs in serverless
mode. These services should have some characteristics:

Loosely coupled distributed service

It brings some essence, being loosely coupled, they do not have


dependency on each other, becomes fast. Being distributed, those
are reliable, secured, stable, you can increase security by
implementing different security strategy to those.

Scalable, secure, fast, easily deployable and replaceable

Services should be scalable separately, being distributed, you can


control the resources engaged serving the API. Security increased
effectively, hacker must work harder to get the security strategy, as
the services are distributed.
Highly maintainable and testable which can easily be
achieved, as being distributed, and enforced by a deployment
strategy with a build pipeline. JAMstack evolved with having a
signature of build strategy

Independently deployable, which also becomes certain, as


those are distributed

Fault Resistant: it must be

Now while you are choosing a right framework for your


Microservices, there are also specific requirements (ref 1), you
need to consider:

Data management

· Database per Service

· Shared database

· Implement queries in a microservice architecture, composing


APIs

· Retrieves data from multiple services

· Event driven tracking & messaging

Transactional messaging

· Transactional message out boxing


· Log tailing

Communication

· Remote Procedure Invocation

· API gateway

· Backend for front-end

Observability

· Log aggregation

· Application metrics

· Audit logging

· Tracing & tracking

· Monitoring

Now it comes the heavy part. While implementing these features,


it becomes essential to integrate external libraries, and that
becomes tricky. It can SLOW your application’s BUILD TIME,
RUN TIME, DEPLOYMENT TIME (ref 2).

Now for today’s implementation strategy, I have chosen NodeJS,


and it’s most popular, Express framework. Choosing NodeJS is
foreseeable, only few words, why Express. This is a framework,
kind of MVC architecture, extending some libraries, secure API’s
can be created with very less time. One thing we have to keep in
mind, which is the API’s must be independent, there must be a
Service Discovery mechanism, and that, which I didn’t
implemented in this demo, leaving on you. May be you can go
through this (ref 3) popular article.

To install and setup:

# Create a new folder, and goto the directory

$ mkdir node-express-routing && cd node-express-routing

# Initialise a new Node project with defaults

$ npm init -y

# Create our entry file

$ touch index.js

# Install Express

$ npm install express — save

# nodemon will also come in handy

$ npm install -D nodemon

#extend libraries

$ npm i express-microservice-starter express-redux mysql


Now it comes to create the services and deployment. I choose 2
very popular ways discussed nowadays

Netlify

# Form starter repo: https://github.com/netlify/create-react-app-


lambda

# Create new site from GIT at https://app.netlify.com

# Once deployed

# Open functions tab and click first “async-dadjoke.js”

# Open site and click “Call Async Lambda”

ApiGee

# Go to https://apigee.com/edge, proxies and create a proxy

# Choose hosted target

# Choose “Hello World” Sample as source (you can change code at


later)

# Don’t keep any authorization for now and check “Add CORS
headers”, other steps keep all default checked and deploy

# “Download revision” from “Project” menu, edit


“apiproxy/resources/hosted/index.js” and “Upload a New
Revision”
External references:

1. https://microservices.io

2. https://medium.com/swlh/micro-service-design-pattern-
dependency-driven-decomposition-ddd-d2d28df2fedc

3. https://learning.oreilly.com/library/view/building-
microservices/9781491950340/

You might also like