0

TLDR; I'm architecting an hybrid multi-tenant app that needs to handle customizations request from customers (tenants), I'm trying to decide between modular monolith and microservices pattern, Which is the best way to handle customization reducing development costs? How should we handle customizations, I mean, How can I now that the size of the module/microservice is the right size?

NOTE:

If the question need clarification or it's confusing please ask in the comments, I will be eager to clarify anything.

If you need more info please let me know, I'm willing to provide it, please try to be gentle this is so confusing for me.

Sorry for this large post but I think this info is relevant to take a decision I highly recommend to read the whole post, this contains the context and research I made about this topic:

CONTEXT

I'm architecting an hybrid multi-tenant app, It must handle customizations, for example: I have a basic (default) coupons functionality, but one customer (tenant) needs to add some particular logic inside coupons functionality.

multi-tenancy

You can read more about multi-tenancy here: https://docs.microsoft.com/en-us/azure/azure-sql/database/saas-tenancy-app-design-patterns

Things to consider:

  1. We are going to deal with customers asking for minimal changes, we counted ~ 120 custom requests we are going to work after launching

  2. We expect to have ~1000 tenants on the first month after launching (they are already pre-registered).

  3. After launching, we can't interrupt the operations of the customers that only want the default app features every time we need to implement some custom feature.

RESEARCH

I'm doing some research about architecture patterns, I found 2 main interesting patterns that I consider resolve my problem:

Microservices Pattern

source: https://towardsdatascience.com/looking-beyond-the-hype-is-modular-monolithic-software-architecture-really-dead-e386191610f8

Here are the characteristics of Microservice Architecture: The whole application is split into separate processes where each process can contain multiple modules.

  1. Contrary to Modular Monoliths or SOA, a Microservice application is split vertically (according to functionality or domains)
  2. The Microservice boundary is external. As a result, Microservices communicates with each other via network calls.
  3. Instead of one single database, each Microservice has its database.
  4. Extra data synchronization is needed due to “database per Microservice”.

microservices

Modular Monolith Pattern

source: https://towardsdatascience.com/looking-beyond-the-hype-is-modular-monolithic-software-architecture-really-dead-e386191610f8

Here are the characteristics of Modular Monolithic Architecture:

  1. The complete Software System is deployed as a whole (all or Nothing)
  2. The Modular boundary is internal and can be crossed easily which can lead to Spaghetti Code (as shown above by yellow lines)
  3. The application runs as one single process
  4. It is one size for all, i.e., one solution for all sizes of application No strict data ownership among modules

modular monolith

What I understand

What I understand so far is:

  1. Each microservice is an app hosted separately and interacts with other microservices using network calls, so I would need to manage multiple servers (kubernetes or docker swarm) and the interactions between microservices(RabbitMQ).

  2. Modular monolith is a single app with modules inside of it, its easier to develop since you don't need to manage different servers and the interactions between modules are simpler, but its harder to handle customization since I will need to recompile and it may cause downtimes to other tenants.

  3. if I choose microservice pattern I would need to invest in a devops team to manage servers and microservices interactions but it's going to be more scalable

  4. if I choose Modular monolith pattern I would need to invest more on each customization.

QUESTIONS

  1. Which pattern should we use to handle customization reducing development costs?
  2. How should we handle customizations?, I mean, How can I now that the size of the module/microservice is the right size?
  3. Which tech stack would you recommend for microservices development and interaction?

EDIT

Customization Example

One real example of what we mean by customization is the following:

The basic app has a Store Functionality it calculates total with price per unit, One customer (tenant) that owns a grocery store doesn't calculate price per unit but he calculates price per kilo after (x) kilos, he asked to us to change the pricing system for his store.

5
  • Define customization. I think many decisions hinge on what specifically will be customized and how it will work. For example, storing a hex color code for the header in a database column versus the client wanting to completely redesign the interface.
    – Dan Wilson
    Sep 28, 2021 at 20:48
  • 1
    This is typically handled with feature flags that can be enabled/disabled per tenant, but again, it depends on the level of customization.
    – Dan Wilson
    Sep 28, 2021 at 20:50
  • Thanks for the feedback @DanWilson !, I already modified my question for you, you can find what I mean by customization under Edit section
    – Ger
    Sep 28, 2021 at 21:28
  • Why not give all tenants the ability to choose between calculating price per unit or price per kilo? That way you avoid customizing anything and you add value for all of your tenants. (Also, you might consider offering that choice on a per product, not tenant, level)
    – John Wu
    Sep 29, 2021 at 17:11
  • 1
    My advice to anyone who asks here if a microservices architecture is the right choice for them is to build a monolithic app instead. If you have to ask, that means you’re not experienced enough to weigh the trade offs. A microservices architecture will introduce a lot of complexity and it’s likely you don’t actually have a single problem it solves.
    – Rik D
    Sep 29, 2021 at 17:44

1 Answer 1

4

To me, the question about customization is orthogonal to the micro services/modular monolith question. I.e. they are not really related.

From what I have read the main benefit of micro-services seem to be reduced inter-team dependencies. Monolithic development have a problem that when the software is released, all teams have to be done with their features. So it requires synchronization between teams, and that becomes more difficult as the number of teams grow. Micro-services solve this by allowing each team to release updates independently. Easier scaling and fault tolerance is a nice bonus.

A modular monolith would still require a single release, so would still require at least some synchronization. But it might still be appropriate for smaller teams where this is less of an issue. I would personally lean towards a modular monolith since I consider microservices a bit over-hyped, but it would entirely depend on your application.

Customization might be done by using feature flags, configuring simple logic expressions, configuration with some kind of simple runtime script, a full on plugin system, or replacing entire software component with customized versions. But I do not see how microservices would solve issues like loading/unloading custmized code without a restart. Unless you have one microservice per customer, you would just move the problem to the microservice.

If you go for some kind of plugin system for customizations there are often ways to manage loading/unloading of code at runtime, but it will probably depend on the language, and may be better to ask in a separate question.

8
  • By orthogonal you mean that microservices/modular monolith decision has nothing to do with customization?
    – Ger
    Sep 29, 2021 at 13:54
  • @Ger Yes, I would consider microservices/modular-monolith to be independent from how you manage customization.
    – JonasH
    Sep 29, 2021 at 14:01
  • With microservices, Do I need to restart everything for everyone if I'm only modifying one microservice?, My idea with microservices was to make the default microservices, and then make one microservice for custom requests, ie, I have a default Store microservice for all the tenants but for the grocery store tenant I would make a custom Store microservice with the required functionality
    – Ger
    Sep 29, 2021 at 14:07
  • What you suggest is to make a plugin system with a modular monolithic base?
    – Ger
    Sep 29, 2021 at 14:18
  • @Ger That would be one possible architecture. But you could also just use one monolithic application instance per customer to do the same thing, where different customers have modules customized or replaced. Each design would have their advantages/disadvantages, but I do not think the need for customization to be the primary reason for selecting between microservices/monolith.
    – JonasH
    Sep 29, 2021 at 14:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.