Pregunta

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 ! :)

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
scroll top