Following this post : In what situations would AJAX long/short polling be preferred over HTML5 WebSockets?
I consider using WebSockets for my application, which I could describe as something like a real time stock price listing. I've read that I could seriously lower the charge of my front servers this way. So just "thinking" to it.
Presently : Every client calls my application every 1 second to get a JSON of datas. Those data are the same for all the users. So every second, one of the frontal Varnish I have calls for a new resources, eg it passes the request to the backend server (a tomcat) that generates a fresh JSON, and then passes it to the varnish with a TTL of 1second. And during 1 second, every client that with ask for the data will take it from the Varnish.
This allow the backend server to be relatively low charged with request, because the varnish take the majority of it.
My question : If now I come to WebSockets (WS) (I may switch from Tomcat to Nodejs for those requests), and my clients requests every second the fresh data.
- Howwould I be able to generate the data for the "first" client, and serves it for all the other clients during the next second ?
- How will I be able to say to the Varnish that this data has a TTL of 1s ?
Thank you in advance for you explanations !