Thoughts on Microservices, Part 1: Does My App Need to Be Microservices-Based?
Microservices are great, but not every app needs them. Read on for further thoughts from a chief architect on the proper application of microservices.
Join the DZone community and get the full member experience.Join For Free
Ok, it's ten minutes past 6:00 pm. I’m on my way from Plovdiv to Sofia, just after the wonderful #jProfessional Plovdiv 2019. Although there are only 130 km between the two cities, an express train takes about two and a half hours to go through the beautiful Balkan mountaines. It's just enough time to summarize some thoughts on microservices I recently had.
Just to mention, #jProfessionals Plovdiv was EPIC! It's totally worth a separate post.
Everybody writes microservices, no matter the reason, for good or for bad. Most of the talk at conferences are about microservices. Every new project is expected to be developed with a microservices architecture. If there is no “Microservices” buzzword, no customers would ever listen to you. Some of the juniors I have on my teams say – “Of course microservices! Is there another way? Monoliths? Ah, they are bad! Why? It’s obvious!”
So, technically, I see everybody trying to make their software with this architecture. Or they say the do microservices, although most projects I’ve seen usually consist of 2–3 fat services. Those projects look like a monolith artificially chunked into pieces that talk REST to each other. People try to decouple these chunked elements as much as they can, but most of the time it’s really obvious that these parts are still logically very coupled and can't live without each other.
I quite often have the following conversation when I consult some project:
– “Ok, you’ve got 40 requests per day. The interface is for internal use. You’ve got a team of four developers. Why are you doing six microservices, you’re routing requests with Istio, you’ve got an angular UI...”
– “Pretty cool, ah?”
– “How do you spread responsibility in the team, each of you develop your own service?”
– “No, everybody is responsible for all of the code.”
– “What will happen if one of the services fails?”
– “We throw an exception and render a 500 error.”
– “How do you deploy it?”
– “We’ve got one Ubuntu VM on AWS right now. There is Docker installed there.”
– “You will run all of the services there?”
– “Yes, and the database.”
– “Will you ever scale?”
– “No... may be up to 50 requests.”
– “What about security?”
– “Oh.. It will run in a secure environment!”
– “What do you mean by secure secure environment?”
– “It will run in the intranet.”
– “Ok, now a general question: what is the problem you are trying to solve with these microservices?”
– “What do you mean?”
– “Why would you split the app into six independent apps?”
– “They are logically split. What’s wrong?”
– “Ok, 50 request per day, it can’t work if one or more services stop… Isn’t a JSF/Vaadin small app just enough for this?”
– “Man! You are such a retrograde!”
I start thinking to myself, well, may be I’m getting old. I believe many C developers think the same about us Java developers – “Look how much overhead they make!”
But still, I wonder, is it really worth making everything into microservices? Will this automatically guard you from all of the architecture problems out there? Or will it create new problems you didn’t have before?
This architecture, in my opinion, should not be considered absolutely universal. Quite often this causes additional and unnecessary overhead. At the same time, most of the developers I know sincerely believe that this is the only way of doing things. They don’t even consider other approaches.
I believe that we as developers/architects should first ask ourselves, “What are the problems we are going to solve when applying a microservices architecture? Do I really need it?”
Before starting on a new project, I personally make a list of answers to a single question: “Why should this app not be a monolith?” If I give myself at least three technical answers different from, “This is modern!”, “Everybody does this!”, “We can do it with one team!”, I start considering microservices as a potential architecture for the app.
And every time I start a new project I remember the dialog above. Does my app deserve to be microservice–based?
This doesn’t mean microservices are bad and monoliths are good. This means we as professionals should make the right choice based on the case at hand. It is very hard to give recipes, but it is always a good idea just to think before applying a certain architecture!
By the way, there are two great talks by Daniel Bryant “Seven deadly sins of microservices” and “Seven (more) deadly sins of microservices” available on YouTube. They are very useful.
The interesting thing is that my current project suits a microservices architecture really nicely. We have several teams developing their own services. The services can run independently and they follow the main idea that “a microservice should be doing one thing, but in the best way!” There will be pressure and scalability issues, but a microservices architecture will help us solve these problems.
I also have some thoughts about the way microservices should be implemented and this will be the subject for the next post.
And yes, the train is a nice place to work. Especially if there is an A/C plug.
Oh, here is Sofia. It has a beautifulyl renewed central station.
'Til next time!
Published at DZone with permission of Dmitry Alexandrov. See the original article here.
Opinions expressed by DZone contributors are their own.