vendredi 11 mai 2018

frontend / backend communication; websockets vs REST?

I'm designing a proof of concept software system to match smartphones with targets. It's a 6-week long project that might get extended in time and scope. Objective of the system is to continuously find matches between single smartphone and single target (1 to 1). I attached two graphics, first one shows high level architecture diagram, second one is example view of a frontend with single match shown in red.

Legend:

Smartphone/phone: GPS (lat/lng) coordinates of actual smartphone held by human. All that data is obtained from 3rd-party REST APIs. My system has multiple scripts/apps (2) to retrieve it and store in database tables (1). Important to note is that coordinates of every smartphone change in real time, so data in phones_table in database (1) also constantly updates.

Target: GPS (lat/lng) coordinates of a non-moving target like a building or intersection.

(1): MySQL database tables storing coordinates of smartphones, coordinates of targets and other relevant data.

(2): Scripts/apps to retrieve real time GPS (lat/lng) coordinates of smartphones through 3rd-party REST APIs.

(3): Script/app to manage targets. E.g. is target available to be matched? Does target currently exist? Are there any new targets?

(4): Script/app that contains secret sauce, algorithm on how to perform matching. The most important part to note is that it always matches one target with one smartphone. Once the match happens, given smartphone and given target are no longer candidates for future matching, at least for some time period.

(5): This is a script/app to facilitate a communication to frontend. Frontend is read-only simple visualization of data.

(6): JavaScript website/frontend that visualizes what happens on the backend using Google Maps. That's really the only goal of website. Traffic here is minimal.

Question:

  • I see two potential solutions for communication between backend (5) and frontend (6): using REST API - (5) becomes REST API, or through a websocket - then (5) would push data updates to (6) only when necessary. What are the pros and cons of these? Is there any other option?

PS. Apparently I cannot post images, here they are:
https://i.stack.imgur.com/1yjoZ.jpg
https://i.stack.imgur.com/jm2s3.png

Diagram graphic prepared using lucidchart.com.
Icons made by Freepik from www.flaticon.com is licensed by CC 3.0 BY
Icons made by Lucy G from www.flaticon.com is licensed by CC 3.0 BY

Aucun commentaire:

Enregistrer un commentaire