12 factor
app pattern
Four-tier application
architecture
Two
key attributes of microservice architecture:
1.
Loosely coupled: means that you
can update the services independently; updating one service doesn’t require
changing any other services.
2.
bounded context: A
microservice with correctly bounded context is self‑contained for the purposes
of software development. You can understand and update the microservice’s code
without knowing anything about the internals of its peers, because the
microservices and its peers interact strictly through APIs and so don’t share
data structures, database schemata, or other internal representations of
objects.
Best
practices for designing a microservices architecture:
1.
Create a separate
data store for each microservice.
2.
Keep code at a similar
level of maturity: if you need to add or rewrite some of the code in a deployed
microservice that is working well, create a new microservice for the new or
changed code. Then deploy and test the
new one. Then merge/combine them.
3.
Do a separate build
for each microservice.
4.
Deploy in
containers.
5.
Treat servers as
stateless.
API Gateway
· Ngnix
· Netflix Zuul 1
· Spring Cloud Gateway
· Linkerd
Their performance comparison:
https://engineering.opsgenie.com/comparing-api-gateway-performances-nginx-vs-zuul-vs-spring-cloud-gateway-vs-linkerd-b2cc59c65369
OpenAPI
OpenAPI Specification (formerly known as Swagger spec)
is the industry standard for defining REST APIs.
Sample:
swagger:
"2.0"
info:
title: "Airport Codes"
description: "Get the name of an airport from its three-letter IATA code."
version: "1.0.0"
# This field will be replaced by the deploy_api.sh script.
host: "YOUR-PROJECT-ID.appspot.com"
schemes:
- "https"
paths:
"/airportName":
get:
description: "Get the airport name for a given IATA code."
operationId: "airportName"
parameters:
-
name: iataCode
in: query
required: true
type: string
responses:
200:
description: "Success."
schema:
type: string
400:
description: "The IATA code is invalid or missing."
info:
title: "Airport Codes"
description: "Get the name of an airport from its three-letter IATA code."
version: "1.0.0"
# This field will be replaced by the deploy_api.sh script.
host: "YOUR-PROJECT-ID.appspot.com"
schemes:
- "https"
paths:
"/airportName":
get:
description: "Get the airport name for a given IATA code."
operationId: "airportName"
parameters:
-
name: iataCode
in: query
required: true
type: string
responses:
200:
description: "Success."
schema:
type: string
400:
description: "The IATA code is invalid or missing."
API spec edit APICURIO:
hapi-swagger: