N
N
Nikolai Kochnev2016-04-10 12:23:47
SQL
Nikolai Kochnev, 2016-04-10 12:23:47

When to use microservices and when to use database join?

During the development of one of the services, my colleague and I had an architectural conflict, we need an outside perspective.
The main function of the developed service is sending data from our system to an external one. In the process of data preparation, it is necessary to convert our address identifiers into FIAS. To do this, we have another microservice that keeps the FIAS database up to date and links with our address system.
You can connect the data of two services in two ways:
1. via http: the fias service provides an api for receiving data, the sending service pulls the necessary methods and collects data in the application
2. through a simple join of the necessary tables in the stored procedure for lifting the data of the sending service, the data is collected in the database
First approach:
- separation of responsibility of services
- independent data storage: when transferring a database from one server to another, no changes need to be made to client services
- more control over the application, testability
Second approach:
- higher performance
Question: which approach to choose? What are the pros / cons of both approaches that we have not taken into account?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ananiev, 2016-04-10
@nkochnev

Obviously the first one. The second one will cause a lot of problems when changing the structure of the database

M
Maxim Kuznetsov, 2016-04-12
@max-kuznetsov

The first approach requires the constant availability of an external third-party service. Without this, it won't work at all. I would make a cache of the necessary data in my system, updated at a given frequency by a client connecting to a service on the FIAS side (going into a database, especially someone else's, is not directly comme il faut). The advantage of such a cache is that your system will work regardless of whether the data source is available on the FIAS side or not. Another plus is the abstraction layer from the FIAS internal infrastructure: the service will change much less often than the database structure. Additionally, you can control the versions of the transmitted data.
And then - a flight of fancy. In addition to these options, there are several other options to consider. For example, according to the schedule in the database, fill in some table-"showcase" of the required format, from which you can directly send data anywhere. This solution is convenient if building a "showcase" takes a long time due to the amount of data. Prepare the data in advance and then immediately give it back.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question