WebSocket Latency Much Higher Than Expected (1000–1500ms vs Claimed 30–50ms)

Hi everyone,

I’m working on a project that uses the Upstox WebSocket API to stream live Nifty 50 LTP data. I’ve implemented the connection using the official sample code provided in the Upstox Developer Docs, and the connection is successfully established.

However, I’m consistently seeing latency values in the range of 1000–1500ms (occasionally even more), as calculated based on the difference between the data timestamp and the system time when the message is received.

Here’s a snippet from my logs for reference:

2025-05-19 11:09:16,930 | INFO | Connection established
2025-05-19 11:09:16,932 | INFO | Subscription request sent.
2025-05-19 11:09:16,953 | INFO | 2025-05-19 11:09:16.000 - Nifty 50 LTP: 25036.75 | Latency: 952.8 ms
2025-05-19 11:09:17,003 | INFO | 2025-05-19 11:09:16.000 - Nifty 50 LTP: 25036.75 | Latency: 1002.5 ms
2025-05-19 11:09:17,452 | INFO | 2025-05-19 11:09:16.000 - Nifty 50 LTP: 25036.45 | Latency: 1452.3 ms
2025-05-19 11:09:18,052 | INFO | 2025-05-19 11:09:17.000 - Nifty 50 LTP: 25036.0 | Latency: 1052.0 ms
2025-05-19 11:09:18,501 | INFO | 2025-05-19 11:09:17.000 - Nifty 50 LTP: 25036.3 | Latency: 1501.3 ms
2025-05-19 11:09:19,071 | INFO | 2025-05-19 11:09:18.000 - Nifty 50 LTP: 25036.35 | Latency: 1071.1 ms
2025-05-19 11:09:19,568 | INFO | 2025-05-19 11:09:18.000 - Nifty 50 LTP: 25036.05 | Latency: 1568.4 ms
2025-05-19 11:09:20,084 | INFO | 2025-05-19 11:09:19.000 - Nifty 50 LTP: 25035.6 | Latency: 1084.8 ms

Can anyone from the team help me with this?
is anyone able to consistently achive sub 100ms latencies?

Any insights would be appreciated!

Thanks in advance

Hi @Devesh_DeV,

Welcome to the Upstox Community!

Thanks for sharing the details. Our team is going to check this and get back to you soon.

The measurement is more accurate when you do a place order and measure the roundtrip latency. That way you can time between when you sent the place order and when you got an acknowledgement back.

With websocket, it’s a unidirectional message. The timestamp in the data packet and your system time can be off due to differences in time synchronization. The different servers that interact between the exchange, us and yours may all be off in timestamp by milliseconds which can skew the measurements.

By measuring the place order API call - your start and end timestamp are both measured in your system time so you’ll get a much more accurate representation of latency. You’ll also notice a big latency difference depending on how close/far you are from our system - if your system is on AWS Mumbai, latency numbers will be considerably less than if your system was anywhere else.

1 Like