My client has two API keys for Alpha Vantage with a limit of 5 requests per minute.
If the limit on one is reached, then I want to use the other.
I am using MongoDB as a database.
I was thinking that we can store a variable in MongoDB, but I'm worried about the performance effects in that case.
What is the best (and simplest) way to do this?
The limit is 5 requests/minute. Requesting it to check if the limit is exceed might increase the total time the request takes to execute.
You can make your requests as needed, and check the return code from the service.
If the service says/indicate "rate limit reached", try the second API key. If the limit of the second one is reached, try the first one again.
And so on.
PS:
There is no need "to check the key" if the limit is reached.
Just make your API call as needed and check the return status.
Just try your keys in a round-robin routine when one reach its limit