Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] so does this mean each microservice run their own database with different schema? #3

Open
simkimsia opened this issue Jun 28, 2019 · 5 comments
Assignees

Comments

@simkimsia
Copy link

simkimsia commented Jun 28, 2019

For example, when the checkout service needs reflect product details such as description, how does it "fetch" this data?

Does it have a duplicate of the production description in its own database? or it fetches it from the product microservice directly? or indirectly via the API gateway?

E,g, I am assuming that checkout microservice is responsible for displaying the checkout list.

image

@rkarthik007
Copy link
Contributor

It fetches the product data from the product microservice using a REST API. Note that the API gateway is present for end user authentication and security purposes. The microservices themselves are free to talk directly to each other using REST calls.

@simkimsia
Copy link
Author

Thanks for reply @rkarthik007

The microservices themselves are free to talk directly to each other using REST calls.

They directly talk with each other without going past the API gateway?

So what does the Order microservice store?

When building a monolithic version, the simplest way is to have a Order, Product, and OrderLineItem table.

What happens is that OrderLineItem has both Order id and Product id.

In the microservice model you have, do you store Product id inside the Order microservice? and do the various microservices access the same database or have their own separate database?

@rkarthik007
Copy link
Contributor

Sorry for the slow response - @ameyb and @nchandrappa: could you folks chip in? You guys are way more knowledgeable about Spring than me.

@nchandrappa
Copy link
Collaborator

nchandrappa commented Jul 24, 2019

They directly talk with each other without going past the API gateway?

API-gateway is used for serving customer/public facing APIs which means the UI App or any other clients that want to make use of the backend services will be served out off of API gateway.

All the backend microservices are aware of each other through eureka service discovery and they don't need to go through the API gateway.

@nchandrappa
Copy link
Collaborator

When building a monolithic version, the simplest way is to have a Order, Product, and OrderLineItem table.
What happens is that OrderLineItem has both Order id and Product id.

In microservices architecture, domain driven design is widely adopted to identify the bounded context of each microservices. At the end of day, advantages of moving to MS architecture is to enable faster prototyping and each of the microservices can progress at their own speed right.

Following this design principle, we have created Products, checkout, cart microservices and none of them share any state. However each of the them are aware of "api-id" which they use for retrieving the necessary information, this is where magic of service discovery and feign clients come in.

Lets consider the checkout functionality,

UI Checkout Button -> API Gateway -> checkout Microservice ( uses product microservice for Product description, cart microservice to retrieve items in cart )

Table Design:
Checkout Microservice -> Products Inventory, orders (order line item)
Products Microservice -> Products description
Cart Microservice -> cart

Checkout microservice is only responsible for performing transactions on Product Inventory and orders table. @simkimsia

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants