What is microservice architecture?

February 24,2020 - 8 min read
What is microservice architecture?

For a couple of decades, several technologies, architectural patterns, and best practices have emerged in the technological space. In this blog, we are going to talk about one such innovation, Microservice Architecture, let’s get started!

Microservice Architecture is basically an architectural style that structures an application as a collection of services. These services are independently deployed and organised around business capabilities. They are maintainable, testable, loosely coupled and are owned by a small team. Each service is responsible for a discrete task and communicates with each other with the help of simple APIs. These services solve a large and complex enterprise problem.

One of the major benefits of Microservices Architecture is that the constituent services are small and hence can be built by a small team. With Microservices, there is improved fault isolation in which if there is an error in one service, the whole application doesn’t stop functioning and when the error is fixed, only the particular service is deployed and not the entire application.

If developers avail the benefits of microservices architecture, it is easier for them to choose a technology stack that is best suited for their application or service. This prevents them from adopting a standardized, one-size-fits-all approach.

The couple of paragraphs above were an explanation of Microservice Architecture. If you have understood the concept well, the next question that might pop up in your head is how can you start and if there are some standard principles which can be followed to build a microservice architecture. The straight answer to this question might be in negative but there are some common themes that several organisations adopted and achieved success. In the segments below, we try to take our readers on a journey of getting started with Microservices Architecture. Let’s get started!

Getting Started with Microservice Architecture

These examples of different themes of microservice architecture would help you get an idea and understand how you can get started with microservice architecture. I hope this segment will help you comprehend what is microservice architecture? In this blog, we discuss eight different themes of microservice architecture that are help you going to start your journey.

  1. Decomposition

    The main aim of a business is to provide value to its end users and there are certain tasks that a business does in order to achieve certain tasks. One method is to define services corresponding to business tasks and one requires a high-level understanding of business. After business requirements and capabilities are identified, developers can build the required services corresponding to each business capability identified. Each of these services is owned by different teams. These different teams are experts in a particular domain and are well versed with the technologies that are best suited for those particular services.

  2. Building and Deploying

    Services are developed by one or more than one small team(s) with the help of appropriate technologies. For example, building a User service portal with the help of Java and using MySQL as a database.

    Once the development phase is over, CI/CD pipelines will be set up. CI servers are used to run automated test cases and deploy services independently to different environments.

  3. Designing Services

    It is very important to carefully design services. Teams need to define and think about the various protocols, communication and other factors while designing services. While designing services, the complexity and implementation details should be hidden. Only what is needed by the service’s clients should be exposed. Unnecessary details should not be exposed as it becomes very difficult to change the service later and it also results in less flexibility in deploying the services independently.

  4. Decentralization

    There is one model where the teams who build the services take care of everything related to that service. Only one team is responsible for developing, deploying, maintaining and supporting it and there are no separate teams for different tasks.

    However, another model is the internal open-source model in which if a developer needs to change anything in a service, then that particular developer can check out the code, work on any feature and submit a PR himself. The developer doesn’t need to wait for the service owner to pick up and work on any changes.

    In this approach, a proper technical documentation along with setup instructions for each service is required. This makes it easy for anyone to work on the service. Decentralisation is a popular approach followed by many, one advantage of it is that it encourages developers to write high quality code as they know that the code is accessible to others also.

  5. Deployment

    It is good practice to write Consumer Driven Contracts. They are generally written for APIs that are being depended upon so that new changes in those APIs don’t break them.

    Consumer Driven Contracts must pass completely before any changes are made to the API as it helps the provider to know what services are dependent on it and how others are depending on it.

    There are two common models for deploying independent microservices, one is Multiple Microservices Per Operating System and another is One Microservice Per Operating System.

    In the first model, as the name suggests, multiple microservices per operating system can be deployed. The advantage of the model is that it saves time as a lot of things are automated. The disadvantage of this model is that the ability to change and scale services independently is limited and there is difficulty in managing dependencies.

    The next model we mentioned is One Microservice Per Operating System in which, as the name suggests, only one microservice can be deployed per operating system. The advantage of this model is that there is more isolation which makes it easier to independently manage dependencies and scale services.

  6. Standardising

    Standardising is important when there are multiple teams taking care of different services independently. A lack of standardisation forces each service to handle errors differently, and hence a significant amount of unnecessary code is written. Documentation is also an important part of standardisation.

  7. Failure

    Microservices aren’t resilient by default and that there will be failures in services because of a variety of reasons, such as bugs in code, network time outs among others. These failures can also be a result of failures in other services. If one cannot prevent these failures altogether, it is important to ensure that the whole system does not get impacted or not goes down when there is an error in a particular part of the system.

    The resiliency of the system can be achieved by patterns like Bulkhead and Circuits Breaker. We will discuss each of these patterns in brief in the segments below.

    The Bulkhead pattern isolates different elements of one application into pools. The advantage of this is that if one element or component fails, the others will still continue to function.

    The next is the Circuit Breaker pattern that wraps a protected function call into a circuit breaker object. These objects are checked and if a failure crosses a particular threshold then the circuit breaker trips and all further calls to the circuit breaker return with an error. During the period when the circuit breaker is failed, users are notified that a particular part of the system is broken, however, the rest of the system is still not out of order.

  8. Monitoring and Logging

    Microservices are generally distributed in nature and hence monitoring and logging of every service is a big challenge as it is difficult to have a look at and also correlate logs of each service instance and then identify the individual errors. With microservice architecture, there is no one place to monitor all the microservices.

    A probable solution to this problem is to adopt the approach of Log Aggregation. A centralized logging service aggregates logs from each service. The advantage of this approach is that users are able to search these logs from one single spot and raise alerts when certain messages appear.

    Another solution similar to log aggregation is Stats Aggregation, such as CPU and memory usage are leveraged and stored centrally and there are several tools that push to a central repository and store them in an efficient way. If any of the services are incapable of handling requests, an alert is triggered. There should be health check APIs implemented in each service as these health checks provide us with relevant information on the health of the system.

    A health check client monitors a service or load balancer and invokes an endpoint to check the health of a particular service periodically at regular time intervals. There are certain tools to identify downstream communication problem between services that can occur even if all services are healthy.

    With this we come to an end of our discussion on Microservice Architecture. It basically helps developers in rapid, frequent and most importantly, in reliable delivery of large and complex applications while enabling an organization to evolve their technology stack. We hope you are clear with the concept of microservice architecture is now clear in your mind. We will also be happy to help you with any doubts or queries with anything related to any technology.

    If by any chance you want to enter the world of technology as a web developer, we highly suggest you take up a professional web development course in order to curate a successful journey in the world of technology. This course will help you create a competitive portfolio that will get you your dream job.

  9. Out of the many available, the course that we recommend would be Konfinity’s Web Development Course The course is well-researched and is one of the most beneficial training courses out there. It is developed by experts from IIT DELHI in collaboration with tech companies like Google, Amazon and Microsoft. It is trusted by students and graduates from IIT, DTU, NIT, Amity, DU and more.

    We encourage technocrats like you to join the course to master the art of creating web applications by learning the latest technologies, right from basic HTML to advanced and dynamic websites, in just a span of a few months.

    Konfinity is a great platform for launching a lucrative tech career. We will get you started by helping you get placed in a high paying job. One amazing thing about our course is that no prior coding experience is required to take up our courses. Start your free trial here.