{"id":7768,"date":"2018-08-23T14:30:36","date_gmt":"2018-08-23T17:30:36","guid":{"rendered":"http:\/\/blog.plataformatec.com.br\/?p=7768"},"modified":"2018-08-23T11:03:41","modified_gmt":"2018-08-23T14:03:41","slug":"the-misguiding-mindset-that-you-are-using-and-how-it-is-hindering-your-microservices-architecture","status":"publish","type":"post","link":"http:\/\/blog.plataformatec.com.br\/2018\/08\/the-misguiding-mindset-that-you-are-using-and-how-it-is-hindering-your-microservices-architecture\/","title":{"rendered":"The misguiding mindset that you are using and how it is hindering your microservices architecture"},"content":{"rendered":"

As software developers, we have the bias to see the systems we create from a technical perspective. We have been taught to think like that since the beginning of our careers, and unfortunately it’s the dominant mindset in our industry. The perception that software development is an activity that requires few interpersonal interactions is still strong, and the myth about the “genius loner coder” persists to this day. With microservices this is not different.<\/p>\n

I’ve been working with microservices for some time now, and for most of that time my reasoning about this architecture was aligned with what I just described. When designing new services or making tough architectural decisions, my bias was analysing each alternative with a technical mindset. Very important questions like “How we gonna extract this functionality from the monolith?” or “How we gonna handle this interaction? Event-based or through a REST endpoint?” were always analysed in a technical-first perspective.<\/p>\n

And everything went well for a while, until we started having some problems. In one of the projects I’ve worked on, we constantly faced features that were supposed to be simple to ship but took a lot longer than expected. These same features also required a great deal of alignment with other developers, reducing our speed. Decisions we made in one service ended up impacting the whole organization, and bugs started to appear in unexpected places.<\/p>\n

These problems made me question if something was wrong in the way the services were being designed. This thought seemed odd at first, our client was a mature organization with a great expertise in microservices. But the more I thought about it, the more I got the feeling that even mature organizations can still have their share of problems. Very subtle problems, that are not as obvious to see as a common programming mistake. Weren\u2019t microservices supposed to make us ship faster and in a fault-tolerant way?<\/p>\n

After a lot of thinking and research, I brought together some opinions about building microservices that I’m gonna share with you. But first, let’s expand more the problems of that misguiding mindset…<\/p>\n

The problems of the service-as-code mindset<\/b><\/h2>\n

From now on we gonna talk about Booble, a fictitious car rental company. Booble adopted the microservices architecture a few years ago, after migrating from a standard Rails monolithic application.<\/p>\n

Booble’s architectural direction was that services should be reusable. Each service was created to hold a piece of the platform’s functionality, such as: mailing service, document service, pricing service and vehicle service. Each one of them was extracted in a way as not to duplicate any code or data with other services. If one service needed data from another service, it would have to use a REST API for that, as each service was the authoritative data-source of its domain.<\/p>\n

This architectural decision is what I would call the \u201cservice-as-code\u201d mindset: when designing a new service, we tend to define them in a similar way to how we would define modules – or classes – in a monolith. And by doing that, we may end up with services that, if combined, would pretty much result in the monolith they were extracted from: a \u201cdistributed monolith\u201d. This led Booble to have a myriad of services, and as many times more dependencies between them.<\/p>\n

In time, a series of problems started appearing:<\/p>\n