This document discusses architecture trends from monolith to microservices and serverless. It begins with an overview of monolith applications and their limitations over time. It then covers challenges in transitioning from a monolith to microservices and some strategies for doing so incrementally, such as splitting the frontend from the backend. The document also discusses serverless architectures and third party services. It concludes with tips on logging, monitoring, and considerations around costs, complexity and vendor lock-in for different architectural approaches.
5. Source: 97 Things Every Software Architect Should Know
@betoSalazar
The monolith is our legacy ?
6. The journey
● Overview Monolith - Microservices - Serverless
● Monolith in real life
● Microservices really?
● Third party services and Serverless
● Tips, tricks, pros, cons & code
8. Monolith = Legacy ?
@betoSalazar
Application Server
MONOLITH (EAR | WAR | JAR)
Servlets
EJBs
JPA
Balancer
9. Monolith = Legacy ?
@betoSalazar
Application Server
MONOLITH (EAR | WAR | JAR)
Servlets
EJBs
JPA
Balancer
Customer Payments Loans
Funds
Transfer
N…1 N…
10. Monolith = Legacy ?
@betoSalazar
Application Server
MONOLITH (EAR |
WAR | JAR)
Servlets
EJBs
JPA
Balancer
MONOLITH (EAR |
WAR | JAR)
Servlets
EJBs
JPA
MONOLITH (EAR |
WAR | JAR)
Servlets
EJBs
JPA
MONOLITH (EAR |
WAR | JAR)
Servlets
EJBs
JPA
MONOLITH (EAR |
WAR | JAR)
Servlets
EJBs
JPA
MONOLITH (EAR |
WAR | JAR)
Servlets
EJBs
JPA
MONOLITH (EAR |
WAR | JAR)
Servlets
EJBs
JPA
MONOLITH (EAR |
WAR | JAR)
Servlets
EJBs
JPA
MONOLITH (EAR |
WAR | JAR)
Servlets
EJBs
JPA
11. Monolith = Legacy ?
@betoSalazar
Application Server
Microservicios
(EAR | WAR |
JAR)
Servlets
EJBs
JPA
Application Server
Microservicios
(EAR | WAR |
JAR)
Servlets
EJBs
JPA
Application Server
Microservicios
(EAR | WAR |
JAR)
Servlets
EJBs
JPA
Application Server
Microservicios
(EAR | WAR |
JAR)
Servlets
EJBs
JPA
Application Server
Microservicios
(EAR | WAR |
JAR)
Servlets
EJBs
JPA
Application Server
Microservicios
(EAR | WAR |
JAR)
Servlets
EJBs
JPA
Application Server
Microservicios
(EAR | WAR |
JAR)
Servlets
EJBs
JPA
12. Monolith = Legacy ?
Characteristics
! Attachment to the environment(language, platform & OS)
! Single logical executable, deploy everything at once or nothing at all
! Bottlenecks and Failure of part == failure of whole
! Take months even years getting into production
! Centralized authority slows the delivery process (DBA, OPS, QA)
! Coordinated releases are hard, because brings many changes
together from different teams
@betoSalazar
13. The Monolith vs Microservices
How it looks
http://microservices.io/patterns/monolithic.html http://microservices.io/patterns/microservices.html
@betoSalazar
14. Microservices
Characteristics
! Deployable, executable & scaled independently
! Smaller code modules are easier to understand
! High cohesion, low coupling
! Failure is isolated (Fail one part of the system)
! Independent Teams (decide their own
architecture)
! Polyglot “Plus”
https://martinfowler.com/articles/microservices.html
https://martinfowler.com/bliki/MicroservicePrerequisites.html
@betoSalazar
15. Serverless
Serverless
! Developers code business logic as functions
! Forgetting everything about the servers
provisioning and scaling concerns where the
logic will be executed
! Ephimeral
! Vendor lock-in is a myth
! Multicloud, get the best from each one (AWS,
Oracle Cloud, Google Cloud, AWS, Azure, etc)
! Troubleshooting is hard
@betoSalazar
27. Microservices really ?
The plan of move forward (Microservices -> cloud -> serverless ?)
Everybody are talking about the result (microservices architectural style)
but just a few are showing the painpath
@betoSalazar
28. The Monolith to Microservices
How it looks
http://microservices.io/patterns/monolithic.html http://microservices.io/patterns/microservices.html
@betoSalazar
30. Microservices our experience
@betoSalazar
!Split and establish interfaces (Test)
!Reuse business logic (Test)
!Move in parts the frontend (Evolve)
!Rewrite or refactor the backend (Test)
!Cultural evolution (CI - CD - DevOps)
31. JEE application server (JBoss or WL or WAS)
thebanking.ear
banking-web.war
banking-js.jar
backoffice-web.war
accounts.jar
loans.jar
customers.jar
The Monolith to Microservices
The Monolith
1 to n modules
1 to n modules
Http
Web
Server
@betoSalazar
32. JEE application server (JBoss or WL or WAS)
banking-web.ear
backoffice-web.ear
accounts.ear
loans.ear
customers.ear
The Monolith to Microservices
The Monolith
1 to n modules
Http
Web
Server
@betoSalazar
33. JEE application server
The Monolith
Database
JEE application server
theApp.ear
MODULE1.war
MODULE1-JS.jar
MODULE2.war
MODULE3.war
css.war
MODULE4.war
businesslogic.jar
businesslogic.jar
businesslogic.jar
businesslogic.jar
@betoSalazar
The Monolith to MicroservicesThe Monolith to Microservices
34. Split the frontend from the backend
JSF Controller Code
Call the Facade
The path -> Split the frontend from the backend
@betoSalazar
35. Split the frontend from the backend
Facade Code
Call the Business
Logic
@betoSalazar
The Monolith to MicroservicesThe Monolith to Microservices
36. The communication
JEE application server
theApp-backend.ear
businesslogi
businesslogi
businesslogibusinesslogic.jar
JEE application server
theApp.ear
MODULE1.war
MODULE1-JS.jar
MODULE2.war
MODULE3.war
css.war
MODULE4.war
Database
Message
Queue
Apache ActiveMQ
RabbitMQ
Apache Kafka……
http://activemq.apache.org
https://www.rabbitmq.com
https://kafka.apache.org
producer.jar
http://camel.apache.org/mdc-logging.html
http://camel.apache.org/eip.html
consumer.jar
@betoSalazar
The Monolith to MicroservicesThe Monolith to Microservices
37. Split the frontend from the backend
Call the Processor
@betoSalazar
The Monolith to MicroservicesThe Monolith to Microservices
38. Split the frontend from the backend
Camel Processor Code
Call the Facade
@betoSalazar
The Monolith to MicroservicesThe Monolith to Microservices
39. JEE application server
theApp.ear
MODULE1.war
MODULE1-JS.jar
MODULE2.war
MODULE3.war
css.war
MODULE4.war
Database
Message
Queue
producer.jar
JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jar
JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jar
JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jar
JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jar
JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jar
Split the backend
@betoSalazar
The Monolith to MicroservicesThe Monolith to Microservices
41. Logging, trace & Monitoring
http://www.baeldung.com/mdc-in-log4j-2-logback
https://www.elastic.co/products/elasticsearch
https://www.elastic.co/products/logstash
https://www.elastic.co/products/kibana
logstash
1) Use Mapped Diagnostic Context (MDC)
Enrich log files
2) Introduce a correlationId
3) Collect the logs
4) Search by rest API or use Kibana
Osgi container
engine-orchestrator.jar
Osgi container
dynamic-camel-routes.jar
fat jar
batch.jar
fat jar
services.jar
fat jar
business-module1.jar
fat jar
business-module-n.jar
Service
some api
Service
some api
Service
some api
Service
some api
Service
some api
Service
some api
businesslogic.jar
consumer.jar
businesslogic.jar
consumer.jar
businesslogic.jar
consumer.jar
businesslogic.jar
consumer.jar
businesslogic.jar
consumer.jar
businesslogic.jar
consumer.jar
Monolith to Microservices -> Split the frontend from the backend
@betoSalazar
42. JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jar
JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jar
JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jar
JEE application server
theApp.ear
MODULE1.war
MODULE1-JS.jar
MODULE2.war
MODULE3.war
css.war
MODULE4.war
Database
Message
Queue
producer.jar
JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jar
JEE application server
theApp-backend.ear
businesslogic.jar
consumer.jarRest API
rest-client.jar
Rest-api-layer
Rest-api-layer
Rest-api-layer
Rest-api-layer
Rest-api-layer
Monolith to Microservices -> Split the frontend from the backend
@betoSalazar
44. Microservices or Modules or Microliths
We already split our monolith or we are on it
https://jwt.io/
https://nodejs.org/es/
https://facebook.github.io/react/
https://angular.io/
https://facebook.github.io/react-native/
fat jar
api-gateway.jar
Services
api rest
POST bank.com/api/v1/accouts
POST bank.com/api/v1/accouts
logstash
Login
Angular nodejs
Transaction
Angular nodejs
Module n
Angular nodejs
Osgi container
engine-orchestrator.jar
Osgi container
dynamic-camel-routes.jar
fat jar
batch.jar
fat jar
services.jar
fat jar
business-module1.jar
fat jar
business-module-n.jar
Service
some api
Service
some api
Service
some api
Service
some api
Service
some api
Service
some api
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
JWT
JSON WEB TOKEN
&
Authorization Server
45. Containers - Orchestrators - Cloud Istio: Service Mesh
Containers (Docker) ->
Manage the same code + environment in diferente stages
Orchestrators (Kubernetes, Docker Swarm, Mesos) ->
We need to orchestrated our containers
Cloud (eg. Oracle Cloud, Google Cloud, AWS, Azure, Bluemix)
@betoSalazar
46. The cost of communication over the
network is not trivial.
@betoSalazar
The experience
47. It’s hard to trace the thread of execution in a
distributed system.
@betoSalazar
The experience
50. The experience
Do you depend on a Monolith ?
Provably we will have Bottlenecks
@betoSalazar
51. Do you have an automation pipeline process ?
DELIVERY PIPELINE
CI / CD
CODE BUILD TEST DEPLOY
CODE ANALYZE (Quality and security)
If your answer is not, do it before
microservices
@betoSalazar
54. Serverless
Serverless
! Developers code business logic as functions
! Forgetting everything about the servers
provisioning and scaling concerns where the
logic will be executed
! Ephimeral
! Vendor lock-in is a myth
! Multicloud, get the best from each one (AWS,
Oracle Cloud, Google Cloud, AWS, Azure, etc)
! Troubleshooting is hard
@betoSalazar
56. The cost consideration
@betoSalazar
! Around 262000 requests for 1 USD
• Request / function = 0.000000313 USD + 0.0000035 USD for the API
Gateway fees
• Around 100ms of time for every invocationAWS Lambda, and above the
minimum 128MB memory
!
59. The big picture
Osgi container
engine-orchestrator.jar
Osgi container
dynamic-camel-routes.jar
fat jar
batch.jar
fat jar
services.jar
fat jar
business-module1.jar
fat jar
business-module-n.jar
Service
some api
Service
some api
Service
some api
Service
some api
Service
some api
Service
some api
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
fat jar
api-gateway.jar
Services
api rest
@betoSalazar
60. The big picture
Osgi container
engine-orchestrator.jar
Osgi container
dynamic-camel-routes.jar
fat jar
batch.jar
fat jar
services.jar
fat jar
business-module1.jar
fat jar
business-module-n.jar
Service
some api
Service
some api
Service
some api
Service
some api
Service
some api
Service
some api
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
businesslogic.jar
Rest-api-layer
fat jar
api-gateway.jar
Services
api rest
API Gateway Lambda
Lambda
@betoSalazar
61. Serverless Security
! A user can log in with social network credentials like Facebook, Google
! Returns JWT tokens contain the logged in user
! Use the JSON Web Tokens JWT to validate if a user makes request to a REST Endpoints
! Forget about infrastructure (that’s why we are going serverless, after all) as much as possible;
! Use Auth0 and basically forget about the security details that are behind it.
https://auth0.com
@betoSalazar
63. Reactive systems
Project Reactor
! non-blocking applications
! 10's of millions of messages per second
! Scaling-Out to overcome latency and slow
microservices
https://projectreactor.io
https://projectreactor.io/docs/core/release/reference/
Spring Webflux
https://docs.spring.io/spring/docs/current/spring-framework-reference/web-reactive.html#spring-webflux
! non-blocking HTTP runtimes to the Reactive
Streams API
@betoSalazar
67. The conclusion
Nowadays Architecture Trends
! Nowadays we are dealing with a Distributed
Complex Architecture
! Secure your endpoints is a rule
! The system and services have to deal with:
• network communications,
• failures,
• rebalances,
• splits and refactor
! Our legacy system are only legacy because
they’ve been successful enough to last this long
68. The conclusion
Recommendations
If you can fit your team around a table you maybe don’t need microservices
yet
Hybrid approach and employing monolithic architecture styles when needed
Care about logs, monitoring and always use a CORRELATIONID and MDC (Mapped Diagnostic Context)
Experiment your architecture with small pieces of code and requirements.
Several applications with monolithic architecture is a good fit and there is no need to
change or refactor that architecture
Security - JWT json web token, Json Web Signature, Json Web Encryption
69. Recommendations
To manage changes review the Architectural Clash http://architecturalclash.org
-> In strategy to developed a new way to assess the level of resilience of our frontend
and mobile applications: the Architectural Clash.
Automate the deployment and delivery process -> CI & CD -> DEVOPS Culture
Design for failover, Service load balancing and automatic scaling, data Separation,
Integrity, Performance
If you have monolith dependencies, you probably will have performance issues
The conclusion
Always think about: • Low coupling
• High Cohesion
• SOLID Principales
• CQRS Command Query Responsibility Segregation