Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Are websockets the right technology to be used to update progress bars for the client and how to implement it? [closed]

Scenario

I am developing some sort of web based cloud storage service.

One feature is that the user can initiate transcoding of video files (so that they can be streamed on different devices).

This takes some time and I want to display a progress bar to the user.

My plan is to submit the job using ajax where it is written into a database. The ajax call returns the ID of the job in the database, and this id will be used as the channel for notifications.

So when the job has been submitted, the client subscribes to the channel "job-databaseID" on some self hosted websocket server.

Transcoding workers then periodically select pending jobs from the database table and process them. While processing they push their progress to the websocket server to the same channel where the client is listening.

The front-end application should be a website with javascript and jquery. The back end should be programmed in PHP and MySQL and an apache or nginx webserver.

Question

Is this a proper way of using websockets? Usually I see websockets employed in a on-to-many notification scenario. Here it is a one-to-one notification scenario. Are there maby better alterantives for this kind one way information flow?

Also I often see channels for Websocket scenarios to be more or less long-lived. Here it is very short-lived. Would it maby make more sense to make one channel per user?

What would be a good websocket server for that kind of use? Ideally the channels would be auto-removed once no client is connected to it any more and auto-created the same way, so I don't need to take care of that.

like image 842
The Surrican Avatar asked Feb 13 '23 07:02

The Surrican


1 Answers

Did you take a look at Server Sent Events as you are initiating your request via ajax so you aren't performing bidirectional communication; you only want server to push you updates when it has ones

like image 51
Ihab Khattab Avatar answered Feb 15 '23 10:02

Ihab Khattab