FAQ - WebSocket versus Ajax Requests

WebSocket versus Ajax Requests


What is the main difference between WebSocket and AJAX Requests.

First speed, if a websocket connection is established you are constantly connected to the websocket server and both parties can send data in real time back and forward.

Second Bandwith, HTML5 Web Sockets provide a dramatic reduction of unnecessary network traffic compared to ajax requests. It is also much faster on mobile networks it even runs fast on a simple EDGE connection.

Server Load, it can handle 1000's of connections at the same time.

You can read more if you are interested here: https://www.websocket.org/quantum.html

Even if your chat is not so busy and you can run a PHP Daemon you should think about it. All modern Browser and Mobile Phones can establish a WebSocket connection and therefore it is a total win win situation.

However you also have to know that PHP WebSockets are not 100% stable and also need much more knowledge to maintain.