Skip to main content

Microservices Architecture and Preferred Design Pattern

Microservice Architecture and prefered Design Pattern

Microservices are designed to offer greater agility and operational efficiency for the enterprises. My goals and principles for a microservice architecture are Continuous and faster delivery through DevOps, Built around business context (better business-developer coordination), Reduced cost, Independently deployable, Decentralized, Small and maintainable code.

Microservices is all about building around business domain or business context, creating decoupled code and making services loosely coupled, applying the single responsibility principle. A business context could be defined using DDD(domain driven design concept), It is something that a business does in order to generate value. A business context often corresponds to a business objective, e.g.

  • Order Management is responsible for orders
  • Customer Management is responsible for customers

Decompose by Subdomain

Decomposing an application using business capabilities might be a good start, but you will come across so-called "God Classes" which will not be easy to decompose. These classes will be common among multiple services, you can think of it as helper, utility and library functions. 

Define services corresponding to Domain-Driven Design (DDD) subdomains. DDD refers to the application's problem space — the business — as the domain. A domain consists of multiple subdomains. Each subdomain corresponds to a different part of the business. For example, let's define subdomain for order management :

  • Product search engine service
  • Cart service
  • Order post service
  • Payment confirmation services
  • Warehouse inventory services
  • Shipping services
  • Order completion service

Event Sourcing

Most applications work with data, and the typical approach is for the application to maintain the current state. For example, in the traditional create, read, update, and delete (CRUD) model a typical data process is to read data from the store. It contains limitations of locking the data with often using transactions.

The Event Sourcing pattern defines an approach to handling operations on data that's driven by a sequence of events, each of which is recorded in an append-only store. Application code sends a series of events that imperatively describe each action that has occurred on the data to the event store, where they're persisted. Each event represents a set of changes to the data (such as AddedItemToOrder).


Aggregator Pattern

It helps to address collaborate the data returned by each service, aggregate the data from different services and then send the final response to the consumer. This can be done in two ways:

  1. A composite microservice will make calls to all the required microservices, consolidate the data, and transform the data before sending back.
  2. An API Gateway can also partition the request to multiple microservices and aggregate the data before sending it to the consumer.

It is recommended if any business logic is to be applied, then choose a composite microservice. Otherwise, the API Gateway is the established solution.

Cloud Native for Microservices

Cloud native is a term used to describe container-based environments. Cloud-native technologies are used to develop applications built with services packaged in containers, deployed as Microservices and managed on elastic infrastructure through agile DevOps processes and continuous delivery workflows.

Service Discovery

A service registry needs to be created which will keep the metadata of each producer service and specification for each. A service instance should register to the registry when starting and should de-register when shutting down. There are two types of service discovery:

  • client-side : eg: Netflix Eureka
  • Server-side : eg: AWS ALB.

CI/CD Pipeline WorkFlow with Kubernetes

Goal should be automate the rollout process including checkout, build/compile, run unit test, build Docker Image, push to Docker repository, Pull from repository, Deploy app on Kubernetes, Kubernetes Zero downtime deployment

Happy coding !

Regards
--
Deepesh Rajpal | c: 98282.38079 | rajpal.deepesh@gmail.com

Comments

Popular posts from this blog

Installing BEA Weblogic 10.3 on Mac/OSx

Updated post:- I have to go through a long hassle of making Weblogic work on my MacBook. Few things which I learned and would like to share: -Before starting to install you have to trick the installer into thinking that the local JDK is the generic Sun JDK. If you skip this step the installer will not accept the default Mac OS X JDK and complain that it is Invalid. $ cd /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home $ sudo mkdir -p jre/lib $ cd jre/lib $ sudo touch rt.jar $ sudo touch core.jar -To Install, run the following command from terminal : (Updated for the "fatal error occurred while installing 10.3.2") $ java -Xms256m -Xmx1024m -XX:PermSize=128m -XX:MaxPermSize=256m -jar -Dos.name=unix -jar server103_generic.jar -Once installation is completed, Create a new domain through "./config.sh" from "/bea/wlserver_103/common/bin" -Once the domain is created: --Need to update the env setting in " .setDomainEnv.sh " file i.e. locat...

DIABETES - ITS EARLY SYMPTOMS

Diabetes, especially Type-2 diabetes is often termed as the 'silent killer disease'. Why? The reason behind it is that this disease does not come with prominent symptoms. Sometimes this disease is not detected until the condition gets severe. However, there are certain symptoms of Type-1 and Type-2 Diabetes, which one should know, in order to identify this ailment at an earlier stage. Let us gain an elaborative insight about this chronic disease and the warning signs that it comes with. 1. Intensive Thirst One of the earliest symptoms of diabetes is peeing more than regular. A normal individual usually pees for 4-7 times in a day but a diabetic might do much more than that. This in turn also leads to intensive thirst as the person starts feeling much thirstier than usual. Why does this happen? This happen because the glucose, which your body reabsorbs in normal conditions, is not able to do so when your blood sugar level goes up. 2. Dry Mouth Lack of necessary amount of fluids...

DEPRESSION – HOW TO FIGHT IT

‘Depression’ is a condition which is quite prevalent these days courtesy a hectic lifestyle. One might think that this condition is an imaginary one where it is just all in the head, however, on the contrary, depression is a ‘real’ disease, which has an extremely adverse effect on the brain. There are several reasons, apart from changes in the brain chemistry, that lead to depression which include difficult life situations, stress or any other medical condition. There are many symptoms that are associated with this disease that are commonly found in people who are suffering from depression. These symptoms include: a) Angry Outbursts b) Mood Swings  c) Withdrawal from people d) Losing interest in any activity e) Immense Sadness f) Hallucination  g) Lack Of Sleep h) Concentration Problems  Depression is a common problem. Several studies suggest that one in every 5 women and one in every 10 men suffer from the problem of depression. How to fight this disease? Is ther...