2

We have a pretty big monolith. We're currently looking at carving it up into micro-services.

Right now we have a file server micro-service (FS) that handles delivering files to clients based on certain criteria.
FS has it's own database that contains meta-data relating to each file. So when a client requests a file FS processes the params, asks another service it's opinion, and decides which file to return. FS's database is quite comprehensive, it contains most of the information relating to each file.

We have another scheduler service (SS) that decides when a client needs to update it's files.
SS also has a database that duplicates a lot of the information that's already in the FS database.
Currently we are looking at moving SS into a micro-service.
Much of the information in the SS database can be queried from a new API in FS. But some of the information we need fast access to in SS and so don't want to add the latency of making API calls from SS to FS.
What are some options for solving this within micro-service best practice?
There is talk of allowing FS and SS to access the same database, but I'm against this idea. SS should query FS via an API for information it requires from that database.
The other option is to have some of the information duplicated in both databases and linked via and ID perhaps. What are your thoughts on this as a solution? I think this is the better option of the two.

I'm completely open to any other suggestions you may have.

asked Oct 1, 2019 at 11:53
2
  • 1
    How are the services currently ensuring that the duplicated information is consistent? Or will the duplication be a result of the split into microservices? Commented Oct 1, 2019 at 12:50
  • There is currently a lot of duplicated information. Right now a unique ID is created when someone adds a file to the system (via a webapp that shares the SS database) a unique ID is created, the same info and the new ID is passed to FS which stores it in it's database. If the attempt to save the data to FS fails then the record in SS is deleted and the end user is notified that the upload failed. It is possible for some one with direct db access to cause a mismatch by adding/deleting records manually. This is also something we want to address as much as possible with the fix. Commented Oct 1, 2019 at 13:16

2 Answers 2

1

I'd be inclined to chop it up like:

Microservice 1: (FS) that handles delivering files to clients based on certain criteria.

Microservice A: Repository that returns meta-data relating to each file.

Microservice 2: (SS) that decides when a client needs to update it's files.

Microservice B: Repository that duplicates a lot of the information from A.

And the architecture looks something like:

[1] -- [A] -- ... [some data store, X]

[2] -- [B] -- ... [some data store, Y]

After you get that all set up, sure, you might decide, hey, maybe X and Y should be the same database. That isn't really anything that [A] or [B] need to care very much about, and it definitely isn't anything [1] or [2] need to care about.

answered Oct 31, 2019 at 14:48
0

How the data is modeled and how you present access to your data can be two different things. You lose a lot of the power of a relational database if you don't actually store related information in the same database. There is no reason to have separate databases per service, in fact multiple services connecting to the same database can be a good way to expose different levels of access. Having separate scheduling and file services that both rely on the same underlying database lets you manage access to those features separately, while the data is available to the features so performance is maintained. If separate databases are truly required, then the next best solution is replication for information that needs to be available for reads. What needs to be avoided at essentially all costs is trying to allow multiple databases to read and write the same data as this comes with all sorts of syncing problems that aren't worth solving until you are at a scale that truly requires it.

answered Oct 1, 2019 at 13:55
2
  • But isn't that against the principles of micro-services? For reference we could be dealing with tens of thousands of connections per second at some points. Commented Oct 1, 2019 at 14:03
  • @bot_bot if your micro-services are micro to the point they are being a significant multiplier from requests to connections, it's time to rearchitect and bring them more in line with requests. Commented Oct 3, 2019 at 12:10

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.