3

I'm designing software that will connect to a remote service and send it requests from a local application. This remote service implements a leaky-bucket algorithm to determine whether to process the request, or return an exception.

Documentation for the remote service is thorough. I can design my local application to conform to its requirements as long as they don't change.

That said, the remote service also returns data somewhat like this in its responses to my local application:

quota-max: 18000
quota-remaining: 17998
quota-resetson: 2017-09-03T00:00:00.000Z

(NEW) If the local application fills up the remote service's entire bucket (i.e. uses the entire quota), and then tries to submit one or more further requests anyway, the remote service will respond to each with QuotaExceeded and will not process the requests. I am unsure, and would not like to find out, if there are other implications to regularly causing QuotaExceeded (for instance, if the owners of the remote service would deny access entirely to the local application).

A question my local application always has to answer is:

  • Right now, can I submit a request?

(NEW) If the local application causes the remote service to be over-quota, it will need to be able to understand that the message it tried to send should be resent the next time a send is possible (and should not attempt a resend until that time). It will run in the background, so it can let requests trickle out at a reasonable pace. The local application is actually a service as well; it subscribes to a local database's defined channels, and forms requests for the remote service based on what is happening in the local database.

This leads me to some design questions:

  • Is it a good idea to always determine "can I submit" solely from:

    • data I track in the local application regarding when previous requests were made?
    • data returned by the remote service regarding the state of the leaky bucket at the time of the last request?
  • Would it be over-engineering to track "can I submit" using both locally-tracked data, and data returned by the remote service?


The answers, I realize, may be subjective. I have read Stack Overflow's "Good Subjective, Bad Subjective". I do hope someone has had experience designing a system that had to do something very similar, and can share their experience in the form of an answer (#4 under "Guidelines for Great Subjective Questions"). Please do back up with facts/references if possible (#5).

  • Thanks to those who have up-voted this question! Is there anything I can add to it that will help others to answer it? – rvrabbit Sep 9 '17 at 18:17
  • Will they return error messages to indicate that you are over quota? – simbo1905 Sep 10 '17 at 17:32
  • What are the application implications of being over quota? – simbo1905 Sep 10 '17 at 17:32
  • Can you avoid going over quota by using the service less between quota resets? – simbo1905 Sep 10 '17 at 17:33
  • (Some questions to make it easier to answer as what is over engineering might depend on the context of your application) – simbo1905 Sep 10 '17 at 17:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.