bybit-exchange / pybit

Official Python3 API connector for Bybit's HTTP and WebSockets APIs.
Other
344 stars 114 forks source link

Subscribe to multiple order websocket streams #176

Closed Chenger1 closed 7 months ago

Chenger1 commented 7 months ago

What is the best way to handle hundreds and event thousands connections? As i understand, it is not possible to subscribe on multiple users streams using single websocket connections. But, there are limits on 500 connections for 5 minutes. So, opening 500 connections each 5 minutes is the best way?

dextertd commented 7 months ago

Your understanding is correct, you'll need to open several websocket connections – on pybit that would be creating a new websocket object for each user.

As long as you connect no more than 500 websocket connections in 5 minutes you'll be okay. Be careful about opening close to 500 new objects in 5 minutes, as in the case of websocket disconnect pybit will automatically attempt to reconnect, which will count towards the 500 limit.

Chenger1 commented 7 months ago

One more question. If i want to open 5000 connections i have ways: 1) Open 500 every 5 minutes until total number reached 5000 2) Build infrastructure with multiple servers, each has its own ip address and distribute connections between them 3) Combination of 1 and 2 Right?

dextertd commented 7 months ago

Yes

Chenger1 commented 7 months ago

Thank you