Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Devnexus - Nowadays Architecture Trends, from Monolith to Microservices and Serverless

375 views

Published on

In this session, attendees will learn about a real-world evolution to a Distributed Architecture without being involved of a complete Microservices Madness; we will be covering tips and tricks of an experience of a evolution of a huge EAR Core Banking Application and how we evolve to a modern distributed Architecture until the evolution of use 3rd party services and Serverless; tips, tricks, pros, cons and the reasons for being involved on move forward and present sample code as FaaS and explain the pitfalls of Serverless and the security concerns on this evolution. We will be using snippets code based on JAVA, JWT, JWS, Auth0, Spring Boot, Reactor, Webflux, Spring Cloud Gateway and Spring Cloud Functions.

Published in: Software
  • ⇒ www.HelpWriting.net ⇐ is a good website if you’re looking to get your essay written for you. You can also request things like research papers or dissertations. It’s really convenient and helpful.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

Devnexus - Nowadays Architecture Trends, from Monolith to Microservices and Serverless

  1. 1. asalazar@advlatam.com @betoSalazar Nowadays Architecture Trends, from Monolith to Microservices and Serverless Alberto Salazar, CTO Advance Latam, Java Champion Auth0 Ambassador Oracle Groundbreaker Ambassador 8th March 2019
  2. 2. Alberto Salazar @betoSalazar www.advlatam.com www.cloudbanco.com www.ecuadorjug.org www.javaday.ec ● Author ● Speaker ● Community ● Java Champion ● Groundbreaker ● Auth0 Ambassador ● Chief Advance Latam
  3. 3. How I get experience? @betoSalazar
  4. 4. The monolith is our legacy ?
  5. 5. Source: 97 Things Every Software Architect Should Know @betoSalazar The monolith is our legacy ?
  6. 6. The journey ● Overview Monolith - Microservices - Serverless ● Monolith in real life ● Microservices really? ● Third party services and Serverless ● Tips, tricks, pros, cons & code
  7. 7. asalazar@advlatam.com @betoSalazar Architecture Trends Overview Monolith - Microservices - Serverless
  8. 8. Monolith = Legacy ? @betoSalazar Application Server MONOLITH (EAR | WAR | JAR) Servlets EJBs JPA Balancer
  9. 9. Monolith = Legacy ? @betoSalazar Application Server MONOLITH (EAR | WAR | JAR) Servlets EJBs JPA Balancer Customer Payments Loans Funds Transfer N…1 N…
  10. 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. 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. 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. 13. The Monolith vs Microservices How it looks http://microservices.io/patterns/monolithic.html http://microservices.io/patterns/microservices.html @betoSalazar
  14. 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. 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
  16. 16. Monolith vs Microservices vs Serverless Monolith Microservices Serverless
  17. 17. asalazar@advlatam.com @betoSalazar The Monolith in real life
  18. 18. Around 2000s Monolith: How it looks
  19. 19. What is the problem ?What is the problem ? Around 2000s
  20. 20. What is the problem ?What is the problem ? @betoSalazar Grow the code and the team
  21. 21. What is the problem ?What is the problem ? @betoSalazar Modular really ?
  22. 22. Monolith: How it looks -> A huge EAR file @betoSalazar
  23. 23. More than 10 Years of code OMG @betoSalazar
  24. 24. @betoSalazar The experience Transactions Scale all or nothing Fail all or nothing Cost of maintenance Coordinate releases Trace and log Only one tech stack
  25. 25. Nowadays Architecture Trends
  26. 26. asalazar@advlatam.com @betoSalazar Microservices really ?
  27. 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. 28. The Monolith to Microservices How it looks http://microservices.io/patterns/monolithic.html http://microservices.io/patterns/microservices.html @betoSalazar
  29. 29. Microservices really ? @betoSalazar
  30. 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. 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. 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. 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. 34. Split the frontend from the backend JSF Controller Code Call the Facade The path -> Split the frontend from the backend @betoSalazar
  35. 35. Split the frontend from the backend Facade Code Call the Business Logic @betoSalazar The Monolith to MicroservicesThe Monolith to Microservices
  36. 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. 37. Split the frontend from the backend Call the Processor @betoSalazar The Monolith to MicroservicesThe Monolith to Microservices
  38. 38. Split the frontend from the backend Camel Processor Code Call the Facade @betoSalazar The Monolith to MicroservicesThe Monolith to Microservices
  39. 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
  40. 40. Split the backend https://projects.spring.io/spring-boot/ https://microprofile.io/ https://vertx.io/ https://www.docker.com/ https://github.com/fabric8io/docker-maven-plugin https://github.com/spotify/docker-maven-plugin Spring boot install just what you need in a Docker Container 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 @betoSalazar The Monolith to Microservices
  41. 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. 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
  43. 43. Microservices Domain based services @betoSalazar
  44. 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. 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. 46. The cost of communication over the network is not trivial. @betoSalazar The experience
  47. 47. It’s hard to trace the thread of execution in a distributed system. @betoSalazar The experience
  48. 48. Eventual consistency ? @betoSalazar
  49. 49. The experience The cost of development goes up. @betoSalazar
  50. 50. The experience Do you depend on a Monolith ? Provably we will have Bottlenecks @betoSalazar
  51. 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
  52. 52. @betoSalazar The experience Lose TransactionsScaling Fail in parts More tech stack Trace and logging Polyglot Easy to understand Lose Single data repo
  53. 53. asalazar@advlatam.com @betoSalazar Serverless FaaS, Backend as Services Third party services
  54. 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
  55. 55. https://cloud.spring.io/spring-cloud-function/ Spring Cloud Functions FaaS ! Promote the implementation of business logic via functions ! Adapters for • AWS Lambda, • Microsoft Azure, • Apache OpenWhisk • and possibly other "serverless" service providers. @betoSalazar
  56. 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 !
  57. 57. @betoSalazar The experience Infra ready(serverless) Troubleshooting is hard If it successful take care about the Cost Cold start time I can create a set of Microservices as Functions Failed fast
  58. 58. asalazar@advlatam.com @betoSalazar The Reality - Tips, tricks, pros , cons
  59. 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. 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. 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
  62. 62. Serverless Security https://auth0.com @betoSalazar
  63. 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
  64. 64. Reactive systems deploy on Oracle Application Container Cloud @betoSalazar
  65. 65. asalazar@advlatam.com @betoSalazar Demo & Code blueprints: https://github.com/lasalazarr/secure-serverless https://github.com/lasalazarr/guide-monolithic-to-microservices
  66. 66. asalazar@advlatam.com @betoSalazar Summary
  67. 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. 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. 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
  70. 70. asalazar@advlatam.com @betoSalazar THANK YOU Auth0 Ambassadors. Helping the developer community make the internet safer.

×