Microservices EVERYWHERE

Sometimes, you just have to wait for a fad to finally consume itself. In the case of microservices, we might need to wait a while. The idea of microservices is not wrong on its own, however it is not a silver bullet we apply and everything suddenly becomes rainbows and unicorns.

Everything is about context.

I dare to say this statement is true in almost all the areas of human activity. The same holds true when to use and when not to use microservices. Microservices are a pattern. When do we apply a pattern? When we need a solution to a problem.

The problem is what matters. The need we are trying to accommodate. Quite often I see patterns blindly applied without the actual comprehension of the underlying issue. What is my favorite reason for using microservices?

“It has to scale.”

If I got a nickel every time I hear this, I’d have been a rentier by now. Let me tell you a secret:

No, it f*cking doesn’t.

In overwhelming majority of cases, there is absolutely ZERO need for any kind of scaling. Nada, null, nothing. It requires awful lot of users accessing our system to force us to scale it. How much data can we keep in a single PostgreSQL database? Well, around 20TB with reasonable response times. How many concurrent requests can we handle on a single machine? Tens of thousands using Spray and Akka.

Postpone going distributed until the last possible moment.

Of course, it boils down to the context again. What we are doing with the data, the constraints we are facing, etc. However, if we believe we need scaling to handle a few tens of users, we should stop right now and immediately rethink and rework whatever we’re trying to achieve.

You might want to argue — but what if our service fails, scaling helps us there, sure? Well, that’s what resiliency is for. Hot-standby setup is likely going to cover most of the situations we encounter. And I’m not arguing just semantics here.

Scalability != resiliency.

Now, what is the likelihood of our product ending up on top of ProductHunt? 0.0001%? There is nothing wrong with being optimistic, but let’s keep it real. Instead of spending our time on making the ultra-mega-dynamically-scalable solution, we could have realized more value for our customers or users.

We are delivering value, not technology.

I’ve just saved us a lot of money right there. Getting back to the topic of microservices, there is my second favorite reason to use microservices:

Our project is a mess, we need to cut it up.

Microservices to save the day, right? Now I’m close to become a billionaire. As the popular saying goes: What is worse than a ball of mud? A distributed ball of mud! Microservices are not going to fix our software development culture. Au contraire, they will complicate our lives immensely in this case. Introducing all the complexities of distributed systems and a state of the art automation into a big mess never goes according to plan.

The true culprit is our wish to untangle the Gordian knot which our codebase started to resemble. Now we need to be honest with ourselves. How did we end up in this mess? Has there been an issue in our process? Did we bite off more than we can chew? Is team acting as a team or bunch of egos? Such an introspection will tell us where to focus the effort when fixing a messed up project. Obviously, using agile and lean practices is a huge win since they incorporate internal feedback mechanisms from the beginning.

So what should we do when we develop software? I suggest following:

Start with a monolith and extract microservices as needed based on strict KPIs.

When our team agrees on this in the beginning of the project, it naturally leads to better internal design of the monolith — since everyone is expecting bits and pieces will be eventually extracted. What are other advantages of such approach?

  1. delivering more business value early on
  2. simplified “devops” in the beginning
  3. avoiding distributed system problems until necessary
  4. time to evolve and adapt the process
  5. extracting only what has to be extracted because of KPIs in place

Such a process offers plenty of leeway to evolve our product while the focus is still on the business value brought to our customers and users. And the value eventually turns into profit :)

I’m looking forward to your feedback.

Like what you read? Give Zdenek Farana a round of applause.

From a quick cheer to a standing ovation, clap to show how much you enjoyed this story.