Answer the question
In order to leave comments, you need to log in
Who will tell you the answer to a number of questions?
Hello. I would like to consult on a number of issues.
There is a certain project constructed on microservice architecture.
Each microservice has two servers under it - one for its work, and the second for its database.
The work is related to geolocation - the exchange of geodata in real time.
1. Is it advisable to introduce "caching" of those users who are online, on a separate microservice, removing those who have disconnected from the socket servers? Caching is just storing users as JSON.
2. The transfer of markers of other users to one of them occurs only if a change in the coordinates or boundaries of the map is registered. To calculate those that fall, the formula (mp.BX-mp.AX) * (mark.Y-mp.AY) - (mp.BY - mp.AY) * (mark.X-mp.AX) is used.
Consequently, users are "run" in a loop and sent to those who have them. But if there will be the same 1 million users on the network, I think that at this rate the server will soon throw back its hooves. How can it be improved?
Answer the question
In order to leave comments, you need to log in
to improve the search for collisions, there are a lot of algorithms, usually they are focused on dividing the "FIELD" into sectors, and looking for collisions only inside points with common sectors.
within a microservice architecture, each "microservice" can serve its own small sector.
your task is to find a profitable scheme for cutting into sectors, I will assume that you will need to use a hashing algorithm (dividing into sectors) with two variables such as (the size and location of the sector and its average load, so that on average there is an equal load of sectors for data processing), the best formula you will need to find by experience.
There are, of course, other approaches as well.
I do not see any need to cache something with users. Better ensure data locality, that is, place data (DB) in the same place where it is processed, this is the main rule for a scalable and productive architecture built on microservices.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question