vendredi 23 avril 2021

Real time application with moving entities on a map

This is more of an architecture question.

Our system needs to receive real time updates on buses locations (every 0.5 to 2 seconds), and eventually display it on an interactive web map.

Our server side is finished, and we implemented a push-notification mechanism to our web application clients using WebSocket. Our architecture is pretty basic:
sensors -> server logic -> database -> server connector -> client (WebSocket)

Our issue: obviously we don't want to display buses that out of the client's zoom in order to avoid high resources consumption.

It seems that we have to options:

  1. The server will not fan-out the updates to all of the clients, rather it will calculate for each client if the update is relevant for him (if the bus's current location is in its zoom).
  2. The client will receive updates on all of the buses but will only draw buses if they're in its zoom.

We also thought about a third option that each client will execute a geospatial query on the database each 0.5 seconds but it seems like not a very scalable solution regarding the large amount of clients that we want to support, and the fact that we cannot really afford a large cluster of databases right now.

My personal opinion was that option no.2 is better since calculating if a location is in a certain radius is not a very heavy operation and it makes server-client communications a lot simpler (client doesn't need to update server on each zoom change).

I'll be happy to hear more opinions, Thanks!




Aucun commentaire:

Enregistrer un commentaire