3

I am planning to use microservice architecture in my project with node- express and this term is new for me.

I researched about it and I came to know that each independent module can be considered as a microservice having a separate database, currently, my project has the same database to all over the module consider below diagram:

Current Architecture:

enter image description here

All the modules(student, school, faculties) share the same DB and always we need one module table data into another module.

Microservices Architecture: enter image description here

Now the problem starts like so we must have the separate DB can't we make three virtual different DB in one DB?

OK if I create three separate DB so can I map one's microservice DB into another microservice for fetching and inserting data and the execution speed will still be boost(as I read that doing separate ms with DB boost your execution speed) as compared to current scenario where I am sharing the same DB and fetching data across the tables in all module?

One question also I have that the big product like OLA, Netflix, Twitter how they are dealing with the microservices if they have different DB and when they want to map the one microservice DB into another microservice?

Please help me out.

lazyCoder
  • 2,544
  • 3
  • 22
  • 41
  • I think there's no need to have different databases for all those modules but rather have each their own REST API that communicates with the same database. – Mulperi Jun 19 '19 at 06:05
  • You mean to say I should only separate the Microservices but that should have single DB right? if this is so then we are not following the microservices concept then – lazyCoder Jun 19 '19 at 06:13
  • 1
    See this answer: https://stackoverflow.com/a/45421864/7970942 – Mulperi Jun 19 '19 at 06:17
  • thanks i got an idea now you can post this answer that is helped me – lazyCoder Jun 19 '19 at 06:23

2 Answers2

1

Microservices - also known as the microservice architecture - is an architectural style that structures an application as a collection of services that are

Highly maintainable and testable Loosely coupled Independently deployable Organized around business capabilities. The microservice architecture enables the continuous delivery/deployment of large, complex applications. It also enables an organization to evolve its technology stack.

From the above explanation the infrastructure is meant to be created in different sections so that when a part of the whole architecture needs to be scaled it can be done independently.We dont need to interfere with the other services.Also if a service is down the whole application doesn't go down. From you example if you create a virtual database in the same database ,and if the database goes down the whole application would do down. Whereas if you deploy the databases separately if the school db goes down the other to db would be up with there services running as well. And also the services should not use databases from other services.

Fiore
  • 33
  • 1
  • 6
  • you said `services should not use databases from other services` but in my case, if I make three separate modules with separate DB then also I need the interconnection of the DBS because my current project is depending on the different tables of different service – lazyCoder Jun 19 '19 at 05:51
  • 1
    if your services depend on other databases from different services ,the microservice architecture is not achieved. Try somehow to seperate the services.If it is not possible then it is in own a service. Services are business logic which could be completely separated and interact with each other through a commong language like json in a very less frequent manner – Fiore Jun 19 '19 at 06:18
1

I think there's no need to have different databases for all those modules but rather have each their own REST API that communicates with the same database.

See this answer: stackoverflow.com/a/45421864/7970942

I hope this helps! :)

Mulperi
  • 1,450
  • 1
  • 14
  • 24