user2337270
user2337270

Reputation: 1243

How do I handle Google DLP rate limiting when using the Java library?

At one point when doing some testing with the Google DLP Java library, I got an exception that indicated that I had exceeded the API rate limit. Unfortunately I don't have the stack trace anymore, so I can't give any more detail at this point. However, it made me realize that I'm not handling that situation in the code. What is the recommended way of dealing with this from a Java application? I haven't seen any examples in the GitHub repo that gives any guidance on this. I'm aware of the ability to request quota increases, and I have already put in a request. My question is on how to gracefully handle this in the code, should I run into the quota exceeded situation again. Thanks.

Upvotes: 0

Views: 342

Answers (1)

Jordanna Chord
Jordanna Chord

Reputation: 995

It depends greatly on your design and place in which you are making the call from.

  • Can you afford to retry until it succeeds?
  • Are user's waiting on the response and errors are not acceptable?
  • Is this a batch pipeline working offline where taking longer is okay?

If you never want to hit the error, you'll need to implement your own client side rate throttling with accompanying monitoring to assure that you know it's time to request more quota.

If you can retry and wait, try retrying using exponential backoff.

Upvotes: 1

Related Questions