Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Advice on which technology to use for real time notifications

I have X amount of activity sensors connected to a server that inserts data to a database everytime a sensor is triggered. What I'm trying to do is create a web interface with a blue print of the facility (svg) and whenever a sensor is triggered, besides the db insert, I want it to show some sort of alert in my blue print. For that I need to keep an open connection to the server I think.

I was thinking of using web sockets, but it might be overkill since I only need to retrieve data from the server. But running an ajax call every second doesn't sound very efficient either. Are there any other alternatives?

Thank you

like image 732
Cornwell Avatar asked Jul 31 '13 10:07

Cornwell


1 Answers

Some potential choices include:

  • WebSocket
  • Adobe® Flash® Socket
  • AJAX long polling
  • AJAX multipart streaming
  • Forever Iframe
  • JSONP Polling

Which actual transport you end up using will depend on the your requirements for browser support and what technology you are using on the server to handle these requests. The transport choice may also depend on your network topology - what types of load balancers you need to integrate with, proxies, etc.

There are many libraries available on both the client and server sides, many of which support more than one of these transports.

For example (not an exhaustive list):

  • socket.io for nodejs
    • WebSocket
    • Adobe® Flash® Socket
    • AJAX long polling
    • AJAX multipart streaming
    • Forever Iframe
    • JSONP Polling
  • SignalR for an asp/.net backend
    • WebSockets
    • Server-Sent Events
    • ForeverFrame
    • Long Polling
  • Atmosphere for a java backend
    • WebSockets
    • Server Side Events (SSE)
    • Long-Polling
    • Forever frame
    • JSONP

IMO - Websockets is NOT overkill for this type of problem and would lend itself nicely to this type of application.

like image 81
dc5 Avatar answered Oct 15 '22 13:10

dc5