2

Is using Websocket (in particular, in a Java, SpringMVC webapp, with the Spring Websocket support libs, but the question probably applies to any language) for a multiple-page website a bad idea ?

I'm currently developing a website that reloads the entire page most of the times during user navigation. One of the requirements is to have a live notifications system.

I know that Websocket is an excellent choice for live events, however I'm not sure if it is only supposed to be used on one-page webapps. I suppose that since my users will navigate between pages, the websocket handshake will have to be remade after each request, which might be bad because of the additional overhead (not so sure though..). However some users might stay on the same page for long periods of time - and I need to be sure that they get notifications right on time - and would prefer to avoid older polling techniques.

Should I totally forget about using Websocket, or is it totally okay to use it on single-page as well as multiple-pages websites ?

Thanks ! :)

  • Can't you have one websocket per page? Your user might simultaneously view different pages in different tabs – Basile Starynkevitch May 19 '15 at 18:28
  • If a user has several tabs open, whether or not for the same view, I'd expect the notifications to be refreshed on each tab at the same time. – niilzon May 19 '15 at 20:33
2

I suppose that since my users will navigate between pages, the websocket handshake will have to be remade after each request, which might be bad because of the additional overhead (not so sure though..).

Bad in what sense? Yes, there will be additional load on your server, but it probably won't be a big deal. Your main goal at this stage should be to get it running and have an architecture that is parallelizable to multiple servers. That way, should your site become really popular, you can spend your way out of inefficiencies temporarily until you can make your site more efficient.

What's really inefficient is optimizing the heck out of your site before you know you have a target market.

  • Ok so I understand that it will indeed cause a little overhead but that it's not necessarily a bad idea to go with Websocket. Thanks – niilzon May 20 '15 at 9:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.