Streaming FX Demo

WebSocket vs. REST

More demosBuild your appDownloadLearn more github-cat-white-black-32  View on GitHub

This demo highlights the performance and accuracy benefits of WebSocket over REST for a streaming data application: real-time foreign currency exchange rates. Please go ahead and pick currency pairs from the following list:
{{currency.symbol}}

On the left of the table below, prices are pushed from the server to your browser using WebSocket. On the right side of the table, your browser is polling at a rate you specify to get the same exchange rates using a REST endpoint. The REST side will always be slightly behind the WebSocket side. The shorter the polling interval the closer REST will get but at the expense of more requests to the server.

Using WebSocket

{{currency.symbol}}
BID: {{currency.webSocket.bid}}({{currency.webSocket.bidChange}})
ASK: {{currency.webSocket.ask}}({{currency.webSocket.askChange}}) -
Server Requests: {{getWsServersAPICalls()}}/s
Estimated Server traffic: {{getWsServersLoad()}} Mbps

Using REST {{speedSlider.value}} msec between calls

{{currency.symbol}}
BID: {{currency.rest.bid}}({{currency.rest.bidChange}}) -
ASK: {{currency.rest.ask}}({{currency.rest.askChange}}) -
Server Requests: {{getRestServersAPICalls()}}/s
Estimated Server traffic: {{getRestServersLoad()}} Mbps
Adjust REST Polling Interval (ms)

The charts above simulate the server impact of increasing the number of simultaneous users