简体   繁体   中英

How do I determine how many 3rd party web api calls my background task will make in production?

My ASP.NET Core MVC web application runs a background task that requests crypto market data from the CoinGecko Api on a set interval. I'm using SignalR to create an open connection between the client and server, so that the displayed data is always up-to-date without the client having to manually request from the server.

CoinGecko has a rate limit of 50 calls/minute. I want to display data for 4 specific coins. Based on the data that I want to display, I'm estimating that I'll have to make 25 calls to update all info. I'll break down the calls:

  • 1 call to /coin/markets to get things like market cap, circulating supply, etc. for all 4 coins
  • 24 calls to /coins/{id}/market_chart to get the 1hour, 1day, 7day, 30day, 90day, and 1year price charts for all 4 coins (4 coins x 6 time intervals)

Assuming I make all 25 calls every minute to keep my data updated, will the number of clients affect the number of API calls I make? I'm guessing that it won't because the data is requested in the back end and then served to all the clients through a SignalR hub.

tldr; You need to make sure you're backend server is correctly caching the API calls.

If the API results are cached on the server, and the cached results are used for the public facing requests, then only the API calls in the background will count.

However, if each public facing request causes an API call, then you will hit the 50/min rate limit after 2 requests.

To Summarize: make sure your server is correctly caching the API calls.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM