Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use exponential backoff with jitter on 429 #110

Merged
merged 1 commit into from
May 3, 2019

Conversation

mhahnenberg
Copy link
Contributor

This can happen if there are too many clients trying to access the same base.
To accomodate this, use exponential backoff instead of a fixed backoff.

@mhahnenberg mhahnenberg force-pushed the mark-exponentialBackoffOn429 branch 2 times, most recently from 23702f6 to f0669fb Compare May 3, 2019 00:06
@EvanHahn EvanHahn self-requested a review May 3, 2019 14:17
Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good other than my small comments!

@@ -6,7 +6,21 @@ var objectToQueryParamString = require('./object_to_query_param_string');
// This will become require('xhr') in the browser.
var request = require('request');

/*
* "Full Jitter" algorithm taken from https://aws.amazon.com/blogs/architecture/exponential-backoff-and-jitter/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: because this is just one line, we can use a // comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

return runActionImpl(base, method, path, queryParams, bodyData, callback, 0);
}

function runActionImpl(base, method, path, queryParams, bodyData, callback, numAttempts) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we only call runAction in one place (from Base.prototype.runAction), I'd prefer to make runAction take numAttempts and call it properply from Base.prototype.runAction.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

lib/internal_config.json Show resolved Hide resolved
This can happen if there are too many clients trying to access the same base.
To accomodate this, use exponential backoff instead of a fixed backoff.
@mhahnenberg mhahnenberg force-pushed the mark-exponentialBackoffOn429 branch from f0669fb to a572e2c Compare May 3, 2019 17:45
Copy link
Contributor

@EvanHahn EvanHahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@EvanHahn EvanHahn merged commit 5b4ad19 into Airtable:master May 3, 2019
@kaz875
Copy link

kaz875 commented Dec 29, 2019

How is the retry mechanism handle the sequencing of requests? Is it somewhat unpredictable or it will always be retried in the order when it's initially fired, during the period of rate limit?

@EvanHahn
Copy link
Contributor

EvanHahn commented Jan 2, 2020

@kaz875 When a request (such as a request to create a record) fails with a 429 status code, it will be retried. As far as Airtable.js is concerned, other requests are not taken into account, and we rely on the JavaScript event loop to handle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants