Category: DevOps

Microservices Best Practices You Should Know

A new trend that we see in DevOps teams is the adoption of microservices, where big and complex applications are broken down into independent and small processes and services. These microservices can communicate with each other through application programming interfaces (APIs). By breaking a monolith into microservices, developers are able to handle applications better, isolate problem areas without shutting the whole application down and focus on completing singular tasks.

While switching to microservices seems like a rather easy task, many developers can underestimate the complexity of the migration process, and that can eventually lead to disastrous results. That is why, before transforming your application’s monolithic architecture into microservices, it is important to set out best practices to avoid any challenges which might arise during the process.

Here are the Microservices Best Practice You Should Know

 1. Understand why do you want to migrate to microservices

Just switching to a microservice architecture because it is the latest technology may not do your organization any good. Switching to microservices can take months depending on your application’s size, and it can also be expensive since you will have to train your resources or hire new DevOps to handle the migration.

After all, if you have a working application that works just fine, then why disrupt that by changing the architecture? There has to be a driving force for the change.

Whether you are facing issues with your application or you want to make it faster, the reason has to be big enough for you to make the shift.

 2. Define what a microservice is

Before planning a strategy for microservices, you need to define what exactly a microservice will entail in your application’s architecture. Depending on your business requirements, you might want to go for medium-sized services, if bigger services align with your business and engineering teams better.

One way to determine the size of a microservice is checking which pieces of code, when changed, create exponential test cases. It is crucial to have a clear idea about what microservices, services, and functions look like for your company, because if you do not, then you could end up with either of these problems:

  •  Your application gets under fragmented, and you are not able to see any benefits of microservices
  • Your application gets over fragmented, and the weight of managing the numerous microservices takes away its value as a whole

 3. Create isolation between microservices at several levels

By isolating microservices from each other, you are able to change them as quickly as possible. Isolation needs to be done at several levels, including:

Runtime processes: One of the most common ways of isolation is differentiating microservices according to runtime processes. This could involve various http management approaches, event architectures, containerization, service meshes, and circuit breakers.

Teams: By partitioning your application, you are able to partition work among teams in a more well-defined manner and give autonomy to the team members as well.

Data: Of course the biggest advantage of implementing a distributed computing technology like microservices is that your data gets partitioned and it re-integrates at the system level.

4. Decide how services will find and communicate with each other

As you are building and deploying microservices separately, you also need to remember that these microservices need to be able to communicate with each other to create a logical workflow and finished application, which from the user’s perspective should look the same as the monolithic application.

While many developers try to hard code the locations of microservices in the source code, it can lead to an array of problems when the location of any of these services need to change. Better alternatives to this problem include a centralized router or a service discovery protocol since both require registration, deregistration, scalability, and high availability.

With service discovery, automatic detection of services becomes possible, and the router is able to work between systems to direct one service towards another. It is the responsibility of service discovery to tell where things are, while centralized router proxies all the traffic.

5. Selecting the right technology

While many companies spend a lot of time selecting the right technology to implement microservices, the truth is, it is rather overvalued. That is because most of the modern computing languages are equally flexible and fast. Most importantly, almost any problem can be solved with any technology.

While all languages have their pros and cons, the decision really comes down to personal preferences and not technical reasoning.

Choosing a language for implementing microservices will become a hiring decision since you will need developers on board who are comfortable working with that language. That is why it is also recommended not to mix too many programming languages, as it could make hiring people rather difficult.

In conclusion

Switching to microservice architecture can lead to many challenging. Before you start the migration process, make sure you have real reasons for it, take an incremental approach, and follow all the best practices.

Why Companies Like Netflix, Uber, And Amazon Are Moving Towards Microservices

In case you have been living under a rock, let us break the news for you- Monolith is out, and now most internet companies have moved towards microservice architecture including Netflix, Uber, Amazon, and Apple.

There were many reasons for the shift, but the most important one was that monolithic is a big autonomous unit and handling it becomes more difficult by the day as the monolith grows bigger when you add new functionalities. Even the smallest change or bug fix requires a complete re-coding and re-deploying of a new version of the application. With microservices, all the processes get simplified, scalable, and streamlined as all the functionalities are divided into independent units.

When we focus on the industry disrupting companies like Airbnb, Uber, and Netflix, we see organizations that are continuously building custom software to get a competitive edge. In fact, many of the companies are not even core technology companies. Instead they use software to provide unique offerings. The results, as we know, drive great revenue for the companies.

Why Microservices Is A Better Option For Breaking Down Monoliths

Even with all the various open source tools and products, maintaining and deploying applications on the cloud is still difficult and time-consuming. Since most of these companies were launched over six to seven years ago, they had no other option but to create their own cloud platform on raw infrastructure.

There was a need for management layers between the applications and cloud infrastructure that they were being created. But it still proved to be better than the monolith architecture, since with microservices they can manage all the different operations of the application separately. So, even if a part of the application is down or needs bug fixes, the rest of the application will still be up and running with no downtime.

Let’s discover how companies like Netflix, Uber, and Amazon are moving towards microservices:

Netflix

In 2009, when Netflix started to migrate a monolithic infrastructure to a microservices one, the term ‘microservices’ didn’t even exist anywhere. Working on a monolithic architecture was proving to be difficult for the company with every passing day and the service would have outages whenever Amazon’s servers went down. After moving to microservices, Netflix’s engineers could deploy thousands of different code sections every day.

Forced to write their own entire platform on the cloud, the company has been pretty open about what they learned with the move, and they have even managed to open source many of the components and tools to help the community. Though Netflix hasn’t put up their entire platform code on Github, which could also help new companies. Overall, moving to microservices was incredibly beneficial for Netflix, and it has led to decrease their application’s downtime to a large extent.

Amazon

Back when Amazon was operating on a monolithic architecture, it was difficult for the company to predict and manage the fluctuating website traffic. In fact, the company was losing a lot of money as most of the server capacity was being wasted in downtime. Back in 2001, Amazon’s application was one big monolith.

Even though it was divided into different tiers and those tiers had different components, they were tightly coupled with each other, and they behaved like a monolith. The main focus of the developers was to simplify the entire process, and for that, they pulled out functional units from the code and wrapped them in a web service interface. For instance, there was a separate microservice was calculated the total tax at check out.

The company’s move to Amazon Web Services (AWS) cloud for microservices helped them scale up or down according to the traffic, handle outages better, and save costs as well. Since microservices allows to deploy code continuously, engineers at Amazon now deploy code every 11.7 seconds.

Uber

Just like any other startup, Uber too started with a monolithic architecture for their application. At that point, it seemed cleaner to go with a monolithic core since the company was just operating in San Francisco and only offered the UberBLACK option to users.

But as the ride-sharing startup grew multi-fold, they decided to follow the path of other companies like Amazon, Netflix, and Twitter and moved to microservices. The biggest advantage of migration was, of course, the fact that each microservice can have its own language and framework.

Now, with more than 1300 microservices, Uber focuses on applying microservices patterns that can improve scalability and reliability of the application. With so many microservices, a big focus is also on identifying the ones that are old and not in use anymore. That is why the team always ensures to decommission the old ones regularly.

In conclusion

While its natural for new companies to take the monolithic-first approach because its quick and you can deploy quickly as well, over time, as the monolith gets bigger, breaking it down into microservices becomes the most convenient solution.