Add jitter to avoid thundering herd (#1723)

This commit is contained in:
Andrew Gaul 2021-07-25 10:22:19 +09:00 committed by GitHub
parent 012e6dd8a2
commit 77f0b75d2f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2382,12 +2382,14 @@ int S3fsCurl::RequestPerform(bool dontAddAuthHeaders /*=false*/)
break;
case 500:
case 503:
case 503: {
S3FS_PRN_INFO3("HTTP response code %ld was returned, slowing down", responseCode);
S3FS_PRN_DBG("Body Text: %s", bodydata.str());
sleep(4 << retry_count);
// Add jitter to avoid thundering herd.
unsigned int sleep_time = 2 << retry_count;
sleep(sleep_time + random() % sleep_time);
break;
}
default:
S3FS_PRN_ERR("HTTP response code %ld, returning EIO. Body Text: %s", responseCode, bodydata.str());
result = -EIO;