Notes on Gradle Microservices Monorepo setup

The product I am building/architecting at work these days uses Monorepo[1] for all our Microservices. Our Microservices are primarily built using Java 17 and Spring Boot 2.6.x. For frontend and platform code(Terraform, Helm charts, configuration files, etc) we have different Git repositories. We use Gradle 7.3 as our build tool. We also make use of shared libraries for code reuse. I know people suggest you should avoid using shared libraries in Microservices but as I discussed in an earlier post[2] I think there are valid reasons to use shared libraries in Microservices.

I prefer Monorepo for three main reasons:

  • Better visibility and control. 
  • Atomic code refactoring across Microservices. This is common in the initial phase of development. 
  • Easy Code sharing between Microservices
Continue reading “Notes on Gradle Microservices Monorepo setup”

Working with Configuration Masters in Microservices Architecture

These days I am working on building a next generation mobile banking platform. One of the solutions that I was designing this week was around how to handle configuration masters in Microservices. I am not talking about Microservices configuration properties here. I have not seen much written about this in the context of Microservices . So, I thought let me document the solution that I am going forward with. But, before we do that let’s define what these are configuration masters.

In my terminology configuration masters are those entities of the system that are static yet configurable in nature. Examples of these include IFSC codes for banks, error messages, bank and their icons, account types, status types, etc. In a reasonably big application like mobile banking there will be anywhere between 50-100 configuration master entities. These configuration master entities have three characteristics:

  • They don’t change often. This means they can be cached
  • They don’t change often but you still want the flexibility to update existing items or add new items if required. Typically, they are modified either using database scripts or by exposing APIs that some form of admin portal(used by IT operations people) uses to add new entries or modify existing entry
  • The number of rows per configuration master entity is not more than 1000. This make them suitable for local in-memory caching
Continue reading “Working with Configuration Masters in Microservices Architecture”

When to use shared libraries in Microservices architecture

One of the advantages of Microservices architecture is that it enables components to have deployment independence. Based on my consulting and software development experience deployment independence is often overlooked and very few teams achieve it. Deployment independence is important since it brings true agility and reduces communication overhead between different teams and services. 

Shared libraries make Microservices tightly coupled and introduce hard dependencies. Since, now a team making a change has to ensure that it does not break another service that depends on the shared library. This requires communication between multiple teams. Also, change in a shared library leads to all the services that depend on it to be redeployed.  This leads to long build, release, and deployment times. We might have to consider the deployment order of services as well. All this leads to more synchronization and communication between teams. So, it is recommended that in Microservices architecture teams should avoid using shared libraries. 

Continue reading “When to use shared libraries in Microservices architecture”

Why is it ok to write pass-through services in a Microservices architecture?

This week I had a discussion with one of the developers in my organization on pass-through services. A Pass-through service is a service that wraps an existing service without much logic. Its job is to delegate to the downstream service. The existing service could be legacy service or an external third party API. The developer was questioning the purpose of pass-through services and the amount of development effort that goes in writing and maintaining them. In this post I am sharing the reasons that I gave to the developer to help him understand why pass-through services are not a bad idea and they can be helpful in the long run.

Continue reading “Why is it ok to write pass-through services in a Microservices architecture?”

Generating Microservices Boilerplate with CookieCutter

This week at the office we started work on a big enterprise project. We decided to go with Microservices architecture for the following reasons:

  • We are working on a business domain composed of multiple subdomains
  • The application needs to scale to twice the current load. They already have an application built using legacy technologies. We have to modernize the technology stack along with scaling to twice the current load.
  • Since this is a big project we will have multiple teams working on it. Microservices architecture is well suited for a large and growing engineering team.
  • Help the organization become API first. All the business APIs will be exposed using an enterprise gateway that third parties can integrate with.
Continue reading “Generating Microservices Boilerplate with CookieCutter”

Using Flyway To Manage Database Migration In Spring Boot Microservices Application

Today, I was working on an application that uses Microservices based architecture. Each Microservice had its own schema and they talk to each other using their published contracts.

We wanted to keep database migration script with each Microservice rather than keeping a common module to manage database Migrations. We might later migrate to common module for database migration but we want to start by keeping schema for each Microservice separate.

Continue reading “Using Flyway To Manage Database Migration In Spring Boot Microservices Application”

11 Reasons Why You Are Going To Fail With Microservices

Over the last couple of years I have done architecture review of multiple product teams that are on their digital transformation journey. Most of the teams were building products following Microservices architecture. They had all the right intentions to use Microservices based architecture — faster development, better scalability, smaller independent teams, independent deployment, using the right technology for the job, etc. But, most often I found teams struggling with Microservices. They failed to leverage the benefits of Microservices to their advantage. In this post, I will share reasons why I think teams were struggling with Microservices.

For people new to Microservices I recommend reading Martin Fowler’s article on Microservices. I like the Microservices architecture definition mentioned in the article.

The microservice architectural style is an approach to developing a single application as a suite of small services, each running in its own process and communicating with lightweight mechanisms, often an HTTP resource API. These services are built around business capabilities and independently deployable by fully automated deployment machinery. There is a bare minimum of centralized management of these services, which may be written in different programming languages and use different data storage technologies.

The list of reasons is below:

  1. Management underestimate complexity of developing Microservices
  2. No process to update libraries and tools to the latest versions
  3. Use of shared services for local development
  4. Lack of visibility in their version control hosting platform
  5. No clear definition of a service
  6. No clear strategy on code reuse
  7. Polyglot programming
  8. People dependency
  9. Lack of documentation
  10. Feature over platform maturity
  11. Lack of automated testing

You can read the complete post on Medium.