Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Websockets with PHP and Symfony - network and server architecture

We have a web application that currently uses polling to handle continuous updates.

While switching to long polling may be a small bandaid to the issue, we wanted to implement a Websockets solution that will be durable and scalable.

My question is: what kind of architecture will be needed for this?

I have done some research myself and have found that the typical setup for an enterprise application is something like this: websocket flow

The execution flow of a connection then would be something like this:

  1. Initial handshake
    • Client makes an HTTP Request to Server along with JS to request a Websocket connection
    • Server responds, Header contains the Upgrade directive and switches protocols for that client
    • Websocket Server establishes a Websocket connection with client
  2. Client submits a POST/PUT/etc.
    • Webserver (Apache/Nginx) fetches result from query
    • Webserver sends result to the MQ where it is added to the queue
    • Message is sent to Websocket server from MQ
    • Message is sent back to the client

Is this approach correct? Am I missing anything? Am I understanding something incorrectly?

like image 757
filpa Avatar asked Jun 03 '16 12:06

filpa


1 Answers

Try having a look at this: socketo.me

Kinda gives you an idea. From what I can see, this is fairly similar to what you've envisioned in the architecture diagram you posted.

May also be worth looking at this Stackoverflow question's answer.

like image 190
vsharper Avatar answered Oct 05 '22 03:10

vsharper