Remove unnecessary trailing zeros in websocket updates

Hi,

I’d like to suggest a possible improvement to the websocket updates, that is to remove the unnecessary trailing zeros in the numeric fields.

E.g. instead of sending 9.19880000, the API could send 9.1988 as these two are semantically the same.

The reason for this improvement is to improve the performance of websockets by reducing the amount of data needed to transfer. This reduces your (Binance) cost for paying egress network traffic, as well as making the messages smaller. Smaller messages may be sent faster over the network.

On the client side, it could also be parsed faster.

In one example that I’ve checked, the excess 0s consist around 35% of the data:
(Spot depth order book update message) 1026 bytes

{"data":{"a":[["9.19880000","1366.82000000"],["9.19890000","144.66000000"],["9.20270000","500.00000000"],["9.20670000","0.00000000"],["9.20830000","0.00000000"],["9.21950000","0.00000000"],["9.22360000","7.18000000"]],"b":[["9.19060000","19.68000000"],["9.19050000","103.85000000"],["9.19020000","0.00000000"],["9.19010000","0.00000000"],["9.18990000","0.00000000"],["9.18980000","0.00000000"],["9.18680000","12.78000000"],["9.18590000","0.00000000"],["9.18520000","300.00000000"],["9.18510000","18.90000000"],["9.18370000","0.00000000"],["9.18190000","80.00000000"],["9.17980000","0.00000000"],["9.17880000","100.00000000"],["9.17760000","1802.58000000"],["9.17750000","0.00000000"],["9.17710000","0.00000000"],["9.17590000","350.00000000"],["9.17250000","0.00000000"],["9.16720000","0.00000000"],["9.16220000","300.00000000"],["9.12400000","34.15000000"],["8.95710000","0.00000000"],["8.72910000","13.00000000"]],"s":"DOTUSDT","e":"depthUpdate","E":1609768267975,"U":583779838,"u":583779872},"stream":"dotusdt@depth@100ms"}

With the zeros removed: 648 bytes

{"data":{"a":[["9.1988","1366.82"],["9.1989","144.66"],["9.2027","500"],["9.2067","0"],["9.2083","0"],["9.2195","0"],["9.2236","7.18"]],"b":[["9.1906","19.68"],["9.1905","103.85"],["9.1902","0"],["9.1901","0"],["9.1899","0"],["9.1898","0"],["9.1868","12.78"],["9.1859","0"],["9.1852","300"],["9.1851","18.9"],["9.1837","0"],["9.1819","80"],["9.1798","0"],["9.1788","100"],["9.1776","1802.58"],["9.1775","0"],["9.1771","0"],["9.1759","350"],["9.1725","0"],["9.1672","0"],["9.1622","300"],["9.124","34.15"],["8.9571","0"],["8.7291","13"]],"s":"DOTUSDT","e":"depthUpdate","E":1609768267975,"U":583779838,"u":583779872},"stream":"dotusdt@depth@100ms"}

I hope you consider this.

Hi, thank you for taking time to provide this feedback, we’ll share it internally.

1 Like