Why Microservices ? | Khmer
Why Microservices ? | Khmer


Hi, everyone. So today I’ll talk about microservice and why need to use microservice? we use microservice to build a complex application and to be scale in the future so far in the past, we use monolith it hard to scale our application and got many more problem to clear, let’s go to the next slide now we’re on new slide, Agenda so, first one is briefly explanation of monolith application second one, what’s microservice, why we need it? the third one is microservice gears it about stack technologies, we use to build microservices application and the last one about reference document I”ll add it in description on the next, we’ll talk about monolith architecture as we develop our server-side application by modular hexagonal or layered architecture based normal 3 or 4 layers so, the first layer is presentation layer or we can call controller, use for handling HTTP requests and second layer is business logic or service is a place to write code handle business requirement and all logic before insert data to database we need to validate data & business constraint for the third layer is database access layer or we can call repository which is work directly with database normally used for CRUD such as insert, query or update etc. the last one is application integration layer some application don’t have this layer, we use for integrate with others external application by using REST API, Messaging or SOAP and this is the diagram of most monolith applications the first layer is user interface refer to presentation layer or controller service layer and data access layer and about domain model are classes we use it for mapping table in database to use in our application so on the next we talk about pros & cons of monolith application first we’ll talk about advantage it’s simple to develop as it easy to write code because everything put in the same project and it’s simple to test as each module in the same place so we don’t need any integrations to test or others external services and third on is simple to deploy our entire application pack in the same package only one package as war or jar file as you can see the picture let’s move to disadvantage of monolith as you can see disadvantage seem a lot compare to advantage it take long time to deploy we spend much time with deployment because when our application grow bigger and bigger deployment increase base project size and other things sometime from can be 30 min to 1 hour slow in getting into production meaning that when all modules development in a single application each modules is depend each other we cannot develop in parallel we need to wait one module finish, then other one can start it’s really take time, and slow large code base meaning that our code grow bigger and bigger up to hundred or thousand of classes, it hard to maintenance root cause of maintenance cost in the future like I said so far, it hard to scalable in case we need to scale new features it’s difficult if new features conflict with an old feature it’s serious problem we must deploy entire application in case we fixed a small problem but we need to deploy the whole system need to take a lot of time another problem related to continuous integration development it’s hard, In case we develop a new application as we need to add new features & modules everyday as you know, when something change we need to deploy all things to test it’s really take time and something we got error by conflict with other modules many problems the last one is bugs in some serious case, like memory leak or something else it can bring entire system down now we’re on the main point what’s microservice ? Microservice the idea come from monolith application when grow big, sometime slow down, hard to scale high cost maintenance they starting split monolith application into small services so, in microservices application has its own architecture include databases and programming languages can be difference like PHP or Java they can communicate each other Microservices communicate each other by expose REST API or using RPC or sometime using message based using microservices it can be impacts relationship between application and database because we need to split database schema now I give one example, related to e commerce web application in this example I give two main modules order and inventory if we are using monolith application, I’m sure you will design database schema only one for the whole system both inventory and order got relationship together in our database Now, if we change to use microservices both part must separate into two difference databases and also schema we also we use difference database one with PostgreSQL or another one with MongoDB so, this is main difference part from what we do so far with monolith application I’m recommend you guys check out Domain Driven Design pattern because in this video I don’t have enough time I cannot explain more detail with Domain Driven Design I only want to tell you that it’s a pattern used for split big business domain into a small part from previous example, related to e commerce I choose two parts – inventory and order so, we can split it into 2 parts for each service in case have other part, we can continue spiting more smaller and smaller as we can do it’s easy for us to maintenance in the future and if…. I have more free time I will make video relate to Domain Driven Design in case got more interested from all of you ^^ Now let’s move to microservice architecture this architecture I take e commerce from a previous example as sample I spited it into 4 services actually, it more than this in the bottom are our core services there are three the fist one is accounting service using Oracle as database the second one is order service using CouchDB and the last one, inventory service using MySQL 😀 all services communicate each other by using Rest API or Messaging depend on real use-case In the middle you can see user service we use it for users management by using postgreSQL we also have edge service it’s an API gateway when got request from client application this service will route to core services which service is need by client application- Accounting order service or inventory service to know all services, edge service work closely with discovery service discovery is a service used for register all services when we create a new service we need to register with it it will work with edge service edge will route base on information from discovery service on the top is our client application we can use ReactJS, AngularJS VueJS or other client side you know and now we talk about benefit of microservices so the first one is it’s fast in continue integration development as we split it into small services I give you an other example in order service, we need to add new features we just update and deploy our order service spend less time and low risk we don’t need to deploy the whole system for inventory part they don’t care about our made change becuase it won’t have much side affect to them and we can develop independently by each team meaning that all the team can develop their modules in parallel no need to wait team “A” finish then team “B” start so they can do their job without any blocking an other benefit is free technologies for each team, by we split our into service it equal to one application for example, order service they can use like Java programming or inventory service we Phython so it possible and low cost maintenance by split into simple service so we don’t a ton of resource to maintenance after project go live like I said so far, for deployment we deploy independent another service not complete, so no need to deploy other finish so they can deploy freely not depend on each other ^^ in case in production a stable service so need to worry about break by other team so when other team fixed problem in their service it won’t have problem with stable services it’s easy to scale application when business need new features or modules it won’t conflict with the old features or modules because it run on difference instances and it’s easy to fix bugs or other problems for example order service and inventory service in general order service got high traffic because of user order at this point we need to increase our hardware such as CPU or RAM to meet requirement so if we don’t use microservice we use monolith application, whole system need to increase hardware up to x2, x3 times or more because size of our system, if we use microservice we increase hardware only on order service for inventory service we keep it normal keep everything the same, so we got load balancing and the last one, it’s suitable for complex application and unclear business meaning that business need to change a lot add or remove module in short time for monolith, it’s hard to do when we change it could be affect to other side and it suitable with agile methodology as you know, we split a big task into small sub-tasks and work in parallel at the same time if we develop with monolith, it seem like water fall we need to wait from top and step by step we cannot develop independent it increase our development time so now look at microservice gears this is the stack technologies that I recommend for someone using Java we should use Spring Boot Spring Boot is light weight and pre configuration which is ready for production and second one, we should use spring cloud sometime we use to expose Rest API for communication with other services and many more in Spring Cloud project you guys should check it out I cannot tell you all about it 😛 and the third one, we should use Axon Framework with RabbitMQ or ApacheKafka if we use axon framework you need to understand about Domain Driven Design if you don’t like axon framework you can choose Netflix OSS instead like Eureka for discovery service Ribbon, Zuul, Hystrix… In Netflix OSS there are many projects, you can check it out. those support for microservices development Netflix already success with their platform, that why become open source for us. other one is keycloak it’s identity server, used for users management when we got many services we cannot login on every services we use it for SSO (Single Sign On) Server we login only one time we use all services base on permission the last one I recommend you guys to use docker or other container platforms that you like so why we use container platform first season because we have many services we might thing one service need a server to run it, but actually not true A container platform offer logical package mechanism for virtual environment in the host machine, we have many virtual environments by using container platform for example, Java or Phyton we can create virtual environment for it. which is visualize environment for each container and why we need it? we use it to visualize hardware stack if we don’t use virtual environment, we might need difference hardware and server to deploy and container platform its visualize on operating system level so we can have many containers that can run on OS kernel directly and light weight and share the same OS kernel so it can start our microservice faster In the last slide are reference documents which is I read it to make this slide presentation I also put link in description And I recommend two books you should read it. Domain Driven Design By Eric Evens Another one Cloud Native Java it focus on Microservice with Netflex ‘s framework this is the end of my presentation thank you watching and this my contact any problem you can contact me. I will help if I can 🙂 it this video [Microservice] got more interest from all of you I might create viedos demonstration related to real practice code in the next video See you in the next video Bye bye

6 thoughts on “Why Microservices ? | Khmer”

  1. Kuylim Tith says:

    Should we move to microservices ? Leave your comment down below !! [ONE MORE] — ENGLISH Subtitle available

  2. DK Blaster says:

    I can say we should move to microservice, if a system complex and need to scale.

  3. kimleng lim says:

    Wow !! Thank you guy !! Easy to understand. Your video answer to my question so far.

  4. Channy Sok says:

    idol 😀

  5. Sem Rakky says:

    When release DDD?

  6. Bunthai Deng says:

    I hope you release the demonstration!

Leave a Reply

Your email address will not be published. Required fields are marked *