Microservices: What the basics?

Big MNCs such as Amazon, Google and Netflix are now using microservices architecture for their business needs. The microservices trend is also causing debates about monoliths versus microservices.

Let’s first understand monolithic architecture and how it led to the shift from monolithic architecture to microservices architecture. This will help us understand microservices and their importance in modern times.

What is microservices?

Microservices provide specific business functionality in addition to feature-based services. It is also a collection loosely coupled services that are easily developed, deployed, maintained, and updated.

To put it simply, each service is responsible for solving the business problem and can communicate with the other using a simple set of REST APIs.

Example:

Amazon is a great example of a company that migrates to microservices because they receive many calls from websites and mobile apps as well as from applications that manage the API. Without microservices it’s impossible for them to handle the calls for their two-tiered architecture.

The client does not communicate directly with the microservices. It communicates with API gateway which then communicates with microservices internal. The developer can do parallel development and deployment as shown in the above figure.

Let’s take as an example one stakeholder working on feature 1 and another working on feature 2. This will allow them to develop and deploy independently.

What’s monolithic?

Monolithic is an old way to design and build applications. It also includes layers, i.e. It also contains layers, i.e., User Interface, Business Logic, and Data Interface. Finally, it deploys the codebase as a single files. Monoliths include both server-side and UI logic (see more: https://aisle-won.com/api-vs-ui-testing/). They are packaged in the jar, war, and other files. This figure shows an example of monolithic architecture at a high level.

Example: Stackoverflow

All functions can be managed and served from one location. It also has a large codebase. Take the following example: If a developer wishes to modify or alter the code base, they will need to access the same source code base to make any changes to the entire code stack. If the application is too large, however, it can be difficult to add new features in future sprints.

Monolithic means that all clients are connected to one machine, instead of being linked to one machine. As shown in the figure below, there might be several machines connected to the databases and clients connected to them. This allows horizontal scaling to be achieved even with monolithic architectures.

From monolithic architecture to microservices architecture

Monolithic architecture is an excellent choice for smaller teams and simpler apps. It also offers the advantage of having one code base that has multiple features. As the new features are added to the code base in the next sprints, it will quickly become chaotic and impossible to control. While monolithic architecture has its pros, there are also some drawbacks. Here are some examples.

  • Closely coupled
  • Slow performance
  • Slow, continuous development

Microservices architecture is an architecture that breaks down business logic into smaller suites of services to manage large and complex applications. All microservices communicate using RESTAP. This improves their performance as microservice-based apps may receive 100 API calls from different services to load the website page.

Here are some of our benefits:

  • Flexible and agile
  • Independent development
  • Independent deployment
  • Mixed technology stack

API Gateway in microservices

API gateway can be used to create an abstraction layer. This abstraction layer also routes all requests and responses from anyone outside of the microservice system. Therefore, the front developer does not need to be familiar with every microservice in the backend. It acts as a traffic controller, or ROUTER because it provides a single entry point to all of your microservices.

An API gateway allows one to do:

  • Monitoring systems (measures how often requests are coming in and how long it takes)
  • Authentication
  • Logging
  • Analytics

How can we get started with an API Gateway?

We can either create an API gateway and expose it ourselves, or we can use an open-source API gateway implementation like the one found in the Netflix microservices stack called Zuul.

We can create as many API gateways as we want and then split the calls using load balancers. It’s an entry point to the entire system. If one API gateway goes down, the other gateways will route the call. The following figures show how easy it is to implement an API gateway with KONG.

How did large MNCs shift to microservices?

Uber started its journey as an startup using a monolithic architecture that had very few features such as connecting drivers and riders, billing and payments. The application could only offer one city at a time. San Francisco.

Uber’s growth and expansion into new cities made it difficult to add more features to the app. The old architecture consisted of:

  • Connected passengers & drivers with REST API
  • Three different adapters were included in the APIs and were used to bill, pay, email, and send messages
  • MySQL is a database

UBER gained the following benefits after moving to microservices architecture:

  • Independent services can be scaled up
  • Each module can be assigned to different team members, which increases speed, quality and maintenance of new development and deployment.

Amazon’s online retail store was a “single monolithic app” in the past. Developers faced many challenges due to tight coupling. There are many challenges for developers, such as delays in development and coding issues to scale up or upgrade Amazon’s systems. These problems were overcome by Amazon’s service-oriented architecture, which was the start of what we now refer to as microservices.

As developers worked on the same task over and over to maintain amazon services, productivity began to drop. This is how AWS (Amazon Web Services), was born. It currently sells to many companies around the globe.

Tinder is hosted on the AWS cloud. It doesn’t currently have a web app, but it does have an Android and an iOs application. It uses AWS amplify for building applications, MongoDB Database as a Database, Redis for caching, and an in-memory Database.

The below diagram shows how the client communicates with the routing/gateway service via web sockets and HTTP long pole. Next, the client connects to the microservices.

Conclusion

Both architectures can be used in their respective places depending on the project’s requirements. It is important to think about the size of your team, how flexible you are towards development and deployment, and other factors.

Monolithic may be an option for small teams. It also saves time during the initial development stage. Microservices architecture is another option for large/complex applications. It allows for more flexibility and allows for the division of tasks in the development team.

Leave a Reply

Your email address will not be published.