I have to collect real timer ticker data on trading pairs (usd/eur etc) from APIs of different sites. The data is usually a small JSON object with mostly ~10 numbers. The naive strategy is to make a request every 5 or so seconds to get the up-to-date ticker data of each of those sites. Some of them, though, provide a websocket option, which allows them to notify me directly when a change occurs, and, I believe, is more efficient. The issue is some of those sites don't offer that option, so the overall code will be simpler to organize and read if I use the same method for all sites (ie, http requests). I'm also not sure the data is heavyweight enough to justify that choice.
From the experts who dealt with similar situations, is this case one where a relevant performance improvement can be expected from using sockets instead of timed http requests when it is available?
It depends:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.