You are on page 1of 18

Microservices & API Gateway

Johannes Sianipar
18 February 2021
Monolithic vs Microservice

Microservices

Chart 2
Monolithic vs Microservice

Microservices

Chart 3
What is API?

■ Application Programming Interface


■ A part of a computer program
designed to be used or manipulated
by another program
□ as opposed to an interface
designed to be used or
manipulated by a human
■ Computer programs frequently need
to communicate amongst
themselves or with the underlying
operating system.
□ System Call API Microservices

□ http://abc.com/search/pages/resu
lts/
Chart 4
Terms in API

■ HTTP (Hypertext Transfer Protocol) is the primary means of communicating data on the web.
□ HTTP implements a number of “methods,” which tell which direction data is moving and what
should happen to it.
□ The two most common are GET, which pulls data from a server, and POST, which pushes new
data to a server.
■ URL (Uniform Resource Locator) - An address for a resource on the web, such as
https://programminghistorian.org/about.
□ A URL consists of a protocol (http://), domain (programminghistorian.org), and optional path
(/about).
□ A URL describes the location of a specific resource, such as a web page.
□ When reading about APIs, you may see the terms URL, request, URI, or endpoint used to
describe adjacent ideas.
■ JSON (JavaScript Object Notation) is a text-based data storage format that is designed to be
easy to read for both humans and machines.
□ JSON is generally the most common format for returning data through an API, XML being the
second most common.
Microservices
■ REST (REpresentational State Transfer) is an architecture style for designing networked
applications.
□ REST vs SOAP (Simple Object Access Protocol)
□ APIs designed with some or all of these principles in mind are called REST APIs. Chart 5
Why API Gateway

■ How to deal with features such as security,


throttling, caching and monitoring at one place?
■ How to avoid chatty communication between clients
and microservices?
■ How to satisfy the needs of heterogeneous clients?
■ How to route requests to backend microservices?
■ How to discover working microservice instances?
■ How to discover when a microservice instance is not
running?

Microservices

Chart 6
API Gateway

■ Basically, the API Gateway is a reverse proxy to microservices and acts


as a single-entry point into the system.

Microservices

Chart 7
API Gateway

■ Basically, the API Gateway is a reverse proxy to microservices and acts


as a single-entry point into the system.

Microservices

Chart 8
Security in API Gateway

■ Security architecture using OAuth2.0.

Microservices

Chart 9
Service Registry

■ Service registry helps to keep track of these instances.


□ A database containing the network locations of the service instances.
□ Every service instance registers itself on start-up and de-registers on
shutdown.

Microservices

Chart 10
Service Discovery

■ The number and location of service


instances is dynamic.
□ Consequently, your client code needs
to use a more elaborate service
discovery mechanism.
■ There are two main service discovery
patterns:
□ client-side discovery and server side
discovery

Microservices

Chart 11
Orchestration

Microservices

Chart 12
Load Balancing

Microservices

Chart 13
Microservices Framework

■ Java
□ Spring Boot, Dropwizard, Restlet, Spark
■ Python
□ Flask, Falcom, Bottle, Nameko, CherryPy
■ Node JS
■ .Net

Microservices

Chart 14
Microservices Framework

■ Java
□ Spring Boot, Dropwizard, Restlet, Spark
■ Python
□ Flask, Falcom, Bottle, Nameko, CherryPy
■ Node JS
■ .Net

Microservices

Chart 15
Basic Flask Code Example

import flask

app = flask.Flask(__name__)
app.config["DEBUG"] = True

@app.route('/', methods=['GET'])
def home():
return "<h1>Distant Reading Archive</h1><p>This site is a prototype
API for distant reading of science fiction novels.</p>"

Microservices
app.run()

Chart 16
Reference

■ https://www.globallogic.com/wp-content/uploads/2017/08/Microservice-
Architecture-API-Gateway-Considerations.pdf
■ https://www.ibm.com/cloud/architecture/architectures/microservices
■ https://programminghistorian.org/en/lessons/creating-apis-with-python-
and-flask#what-is-an-api

Microservices

Chart 17
Thank you
for your attention!
Johannes Sianipar

You might also like