What are MicroServices? And Why You'll Love Them

By Ben Pepper in GET/technical Posted Nov 26, 2018

So, you have this awesome app. Everyone loves it. You know it, I know it. It’s just the bee’s knees. Awesome! But now, because you made the COOLEST thing ever, more people are using it. That increased traffic has stressed your servers, but more importantly it’s stressing out the company because “We can’t scale fast enough.” What are you to do? Well, I’d be a horrible “blogger” if I didn't at least try to help, so let’s give this post the ol’ college try.

What are Microservices?

Microservices, as the name suggests, are REEEEEALLY small services that make up a single application. Actually, the size (read number of lines of code) is a hard thing to pin down. Basically instead of building millions of lines of code (a monolithic app), you break out the app into logical sections that all perform a specific job. There is no set definition for what constitutes a microservice. It’s more of a guideline, kinda like REST. Is your app doing all the things? Is your app only deployable as a single entity? Then you’re probably looking at a monolithic app. Can you scale a single part of your app to meet current load? Are you able to redeploy just a small subset of your app when you have a new release? Then that’s probably a microservice. Here’s why you’ll love them…

decentralised-data

IMAGE SOURCE: DECENTRALIZED DATA

REASON 1: ANY LANGUAGE

The first reason I can think of is that microservices don’t care what the other microservices are written in. You LOVE elm. Why? I don’t know, but you do. But another team just can’t get enough of the Gems included in Rails. Perfect! Just make sure the data that is sent from Microservice A is structured in the way that Microservice B is expecting. You could write each service in a new and exciting language if you wanted. I wouldn’t, but I’m not going to tell you how to live. That’s your PM’s job.

REASON 2: SIMPLIFIED TESTING

The second reason microservices make sense to me is testing. Have a wonderful NullPointerException laying somewhere in the stack trace? Way to go. But did it come from <insert your favorite file here> or from <that file you hate so much>? Who knows. Time to go on a code safari and find out. With microservices, you get an error in Service B. Cool! Well, B is sent data from Service A. SOOOO, that means that either Service A sent the data incorrectly or Service B spazzed out and threw the error. That means you don’t have to look at C-ZZ. That saves some time. Now you’re less frustrated when you actually find the issue. That’s always nice.

REASON 3: DEPLOYING MADE EASY

The last reason is because I'm running out of focus on this post so I need to wrap it up. Deploying is made easier. When you make a change to a service, you just need to deploy that one service, NOT the entire application. This means less downtime and better user experience. Something's broken, or you have something new to roll out? Awesome! Just a few clicks and it’s out in the wild. This ease of deployment also leads to easier scaling. Your users are using a lot of eventing right now? No worries! Just scale up the service that handles events like webhooks and polling and no one will be the wiser that that one customer who always brings down events was overloading the service for the third time this month.

Lastly, then I promise to let you get back to vastly more entertaining things like watching paint dry. When should do you this? When should you make microservices? If you are working on a monolithic app and paying off some of that technical debt (shameless plug of my own blog, I know), now is the perfect time. Take a hard look at what has been built. Is it still working as well as it could? What improvements can be made? What do you know today about how people use your awesome application that you didn’t know six months ago? Use this time to think forward. You have something that is already addressing current use cases. But what about the future? You have the chance right now to think about what could be. How cool is that?!?! Make the product better, more robust, able to make gold out of frustrated, tired developers. I don’t care, but think about it. You could forever be enshrined in the company’s legacy as the engineer who undertook a wondrous experiment and had it pay dividends in the end. Look at you, you immortal demigod. Way to go.

Mull it over and get back to me.

Read a Related Post →