Microservices and when not to use them

Florian Pfleiderer
Oct 25, 2019 · 7 min read
Image for post
Image for post
Photo by Jonathan Borba on Unsplash

What went wrong?

When the project was started, somebody proposed using microservices. Even though that is not a bad decision per se, there was a time when wide parts of the functionality were still rather foggy, but some developer had decided that they’re gonna need exactly these 10 microservices. As it later turned out, the services had been cut rather bad, implementing functionality always involved changing multiple services, replicating enum values to other services. All in all, they had built a distributed monolith. All the complexity of microservices, but without any of their advantages. An interesting observation is that, even though over time the team learned to hate working on their services, all of them defended the microservices architecture pattern like it’s the holy grail and it will surely bring some benefits in the future.

So, are microservices a bad thing?

Of course not. As I already stated in the introduction, I’m a big fan of microservices myself. But designing them up-front on the drawing board is the bad thing. In my opinion, microservices do emerge when you already know your domain(s) and see an opportunity to pull out a piece that is rather independent from the others and get a real benefit from doing so. When talking about the strangler pattern, people usually refer to legacy software that is split into cool new microservices. But I think it is also a valid option to start developing your all-new piece of software as a single service and pulling out components into services as you go.

Keep it simple!

Image for post
Image for post
Photo by Jo Szczepanska on Unsplash

Cutting is easier than glueing

Extracting a new service from a monolith is by far easier than getting wrongly cut services back together. Unifying data types that have evolved in different ways or might have been saved in different kinds of databases, different programming styles or even languages — putting those pieces back together once you figure out that your services are not cut the right way, requires a considerable amount of work.

Think about communication

Image for post
Image for post
Photo by Eduardo Sánchez on Unsplash

Synchronous communication is expensive…

REST queries cost time. When your requests has to go through several services before returning, these times can quickly accumulate to a length that negatively influences your user experience.

… so asynchronous communication is going to fix that, right?

Asynchronous communication might look like the silver bullet that solves runtime problems of synchronous calls.
But dealing with eventual consistency, message loss (or delivery of the same message multiple times) and distributed logic all have their own problems.

Code generation was not as good as it sounded

Image for post
Image for post
Photo by Wokandapix on Pixabay

Microservices need code to solve their own technical complexity

Microservices can add a lot of value to a project, when needed. When they’re not necessary, they primarily introduce complexity.
To master this complexity, usually many lines of code have to be written. REST clients or message queue subscriptions are just some examples for that.

Image for post
Image for post
source: https://martinfowler.com/bliki/MicroservicePremium.html

Digital Frontiers — Das Blog

Dies ist das Blog der Digital Frontiers GmbH & Co.

Thanks to Benedikt Jerat

Florian Pfleiderer

Written by

Senior Consultant & Co-Founder @dxfrontiers

Digital Frontiers — Das Blog

Dies ist das Blog der Digital Frontiers GmbH & Co. KG (http://www.digitalfrontiers.de). Hier veröffentlichen wir zu Themen, die uns interessieren und bewegen.

Florian Pfleiderer

Written by

Senior Consultant & Co-Founder @dxfrontiers

Digital Frontiers — Das Blog

Dies ist das Blog der Digital Frontiers GmbH & Co. KG (http://www.digitalfrontiers.de). Hier veröffentlichen wir zu Themen, die uns interessieren und bewegen.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store