2
votes

The question is related to microservices, when I have multiple microservices offering features/services that will be ordered and are billable.

I am in fix as to which approach to take,

a) An order and a billing service per billable microservice with their own respective databases. b) A common order management and billing service across all microservices.

One thing that bothers me is that each billable feature/service has a different billing criteria / discounts.

Observing some architectures, came across the following- https://d1jnx9ba8s6j9r.cloudfront.net/blog/wp-content/uploads/2018/02/Microservice-Architecture-Of-UBER-Microservice-Architecture-Edureka-768x762.png

in a blog- https://dzone.com/articles/microservice-architecture-learn-build-and-deploy-a

It depicts billing as a common and very centric to the entire architecture.

Your insights will be highly appreciated.

1

1 Answers

2
votes

From what I've seen so far, people prefer to have a dedicated microservice for Order management because the behavior it does not depend a lot on the type of product that is ordered. Every order has almost the same workflow: placed, waiting for payment, delivered, canceled etc.

The Billing is the same, the behavior does not depend on what kind of products are on the invoice but on how much do they cost, on the payer data and so on.

Regarding data, a dedicated Order management or Billing microservice can own the data that it needs. For example, the Order management own the order line items, order status and delivery details (address, permitted days/hours of delivery); the Billing microservice owns the User's billing details (i.e. address).

Regarding resilience, Order management and Billing should still work even if the other microservices are down. For example, if the Jewelry Product catalog is down and it cannot show jewelries details, the user should be able to cancel his order.

One thing that bothers me is that each billable feature/service has a different billing criteria / discounts.

Maybe each domain (billable feature/service) should have its own Pricing module that is used to compute the line item final price. The Order management is not interested in how/why a product costs X USD; it's only interested in the final price; the same is valid for the Billing.