Play around with Microservices


What is microservice architecture

Microservice architecture is a method of developing software applications as a suite of independently deployable, modular services in which each service runs a unique process and communicates through a well-defined, lightweight mechanism to serve a business goal.

In other words, it is an architectural style that structures an application as a collection of loosely coupled services, which implement business capabilities.

Why to choose Microservice ?

  • Independent Deployment : Simple and modular services are easy to deploy, and since they are autonomous, are less likely to cause system failures when they go wrong.
  • Strong Module Boundaries: Micro-services forces modular structure, which is particularly important for larger projects.
  • Technology Diversity: With microservices you can mix multiple languages (like java, scala etc), development frameworks and data-storage technologies(postgreSQL , elasticsearch, mongoDb etc). You are not restricted to use only single technology.
  • Easily Replaceable: Nowadays many diverse services communicate with each other, it is highly probable that one of the service may fail at one point or another. There could be multiple reasons for failure of the service, including instances when the technology becomes outdated or when the code in the service cannot be developed any further. One characteristic of microservices that helps in these situations is that they are extremely easy to replace and can be reasonably managed.
  • Autonomously developed : Microservices are autonomously developed and deployed, which allows teams to modify and implement services independently of other teams. This is beneficial as it enables the scaling of development without having to require a lot of coordination between the teams. Also the chances of conflicts are reduced.

Challenges with Microservice Architecture

  • Increased complexity: Due to the many developing and moving parts, management of the services becomes much more complex. Instead of one deployment, you need to deploy tens or hundreds of services, which need to work seamlessly together. You also need to ensure all the services are up and running, not running out of disk space or other resources, and remain performant.
  • Network Congestion and Latency: As microservices communicate via APIs through standard protocols, such as HTTP, networking becomes an important factor. Considering that there are hundreds of services in one application, and that requests typically span multiple services, it’s not hard to see how this can impact the overall performance of your application if networking isn’t given a lot of consideration. Also the same data is passed from one service to the next where it’s de-serialized and serialized multiple times which can substantially increase the latency.

Whereas considering some of these practices you can certainly make your microservice better :

1) Data caching or replication, to limit the number of requests

2) Regarding the serialization issues, you can use efficient serialization formats and create a common serialization format across the services. This may reduce some of these steps by allowing one service to pass data along to another service without having to reserialize it again.

  • Data Consistency : As each microservice typically has its own store you must deal with the consistency and integrity challenges that come with decentralized data.
  • Versioning: In monolithic systems, the code consuming an interface will typically be deployed with the implementation of the interface. Breaking changes in interfaces are typically caught during integration testing or during build time. In a microservices world, changes to an interface of a microservice are not necessarily handled by a consuming microservice right away, as they may be on different release cadences. To make sure that the consuming services can still work as expected, all teams need to think through and agree on service versioning techniques. It may also include a problem which may result from version mismatch or incompatibility between different services.

Till now we have learnt what a microservice is, and why do we use it. But until we do something hands-on, we do not get a clear picture.

So i started by building my microservice based application using play framework. I found one activator template for the same named as “playing-microservices”, you can also play with the same template to understand it more.

To get started you can get the template by the given steps:

1) run “activator new” command from the terminal.
It will display you a basic list of templates as shown below :

activator

2) To get “playing-microservices” template, press “Tab” button from keyboard and you will see a big list of available templates including “playing microservices”.

3) Now, you are good to go to explore on microservices.

Keep Coding… Keep Learning 😉

References :

1) https://smartbear.com/learn/api-design/what-are-microservices/


KNOLDUS-advt-sticker

Advertisements
This entry was posted in Microservices, Play Framework, Scala. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s