Help Making a Design Choice, AJAX vs. Websocket

@Qqwy: Good answer! I want to write something similar in my words …

Basically AJAX is good when you are only fetching data from server like using JSON REST API (for example for CMS front page).

WebSocket is required for example if you want to create fast client-server chat application.

Another good example for both Elixir and Phoenix WebSocket is update graph. Simply Elixir could have a process in background that sends event through Websocket, so after data is changed client gets info about it as soon as possible. Here I also recommend new Registry Elixir API that is awesome in combination with Phoenix WebSocket connection. I found a good example for PubSub with WebSocket using this API.

1 Like