Making a Case for Mircroservices

Author: Jarett Lear

Date: April 22, 2016

Benefits of Microservices

The use of microservices has been generating a lot of hype over the last couple years, and with good reason. The rise in popularity and complexity of UI frameworks have paved the way for large scale, enterprise-class applications to be built on the microservices architecture.

The reasons for supporting microservices are well defined, from an engineering and architecture point of view. Microservices allows engineering teams to work to maintain smaller code bases and therefore implement changes faster and with less impact to the overall application. Having multiple teams working in parallel to maintain an application works well in large scale enterprise application development and, with some transparency between the teams, it allows loosely coupled services to act as a single application, from a user’s point of view.

This also means that services can be in different languages, because even though we’re talking about microservices, we can’t leave out the fact that we're also talking about how these services interact with our users, and a big part of that is the UI frameworks. Today's UI frameworks don’t care what the backend looks like; we don’t need to couple UI within the application using some template engine. All we need to do is return data in a way that can be consumed by these frameworks. This takes load off the server side and lets the backend do what it does best: manipulate and return data. We let the web server serve the static content, and we let the browser render the UI. Everyone is doing what they do best, and this decoupling of the UI and backend, combined with the creation of microservices on the backend, creates a quick and scalable application. This also allows faster and more stable feature releases with little or no impact to the rest of the application.

Security is always a big concern with monolithic applications. When multiple teams of developers are working on a single large application, testing and code reviews become an absolute necessity. In a microservices architecture, it becomes more difficult for developers to introduce accidental security issues. Stateless authentication is usually code shared by all the microservices that need it.

Part of the microservices architecture is maintaining some kind of session without storing state on an application server. Because there are so many different services, a user could be presented with a login screen many times per visit, and they may see one every time they make a request, if the services are load balanced. This would be a bad user experience. We handle this by creating a stateless session that passes user info and some kind of token with every request to validate the user session without actually storing anything in state on the application server.

Microservices and UX

Microservices alway benefit users on some level. It could be as simple as a single page application not needing to refresh the browser window, or something as major as preventing a whole service from becoming unavailable. LinkedIn is a popular site that has moved to microservices. With the large amount of traffic, users are bound to notice quickly if there was a problem and the site were to go down. With microservices, you can have a service go down, or become unavailable, without the whole site crashing because of it. You might lose a section of the site until you get it back up, but if you lose the ability to edit your profile and still have access to everything else, it’s a better experience than getting an error on the whole site. Instead of users getting a 404 or a "page not found" error, we can direct them to a maintenance page to let them know what’s going on.

Microservices architecture, in conjunction with UI frameworks, has given developers a way to deploy secure code in a faster and more stable environment. This allows the user to have access to other parts of the application, even while one is undergoing maintenance. It provides a better over all experience by minimizing page reloading in the browser and a faster and more seamless experience between applications.