aws-observability / aws-rum-web

Amazon CloudWatch RUM Web Client
Apache License 2.0
114 stars 65 forks source link

feat: retry with exponential backoff #501

Closed williazz closed 3 months ago

williazz commented 5 months ago

As a best practice, we should do exponential backoff https://docs.aws.amazon.com/prescriptive-guidance/latest/cloud-design-patterns/retry-backoff.html


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

qhanam commented 3 months ago

Currently, PutRumEvents requests (i.e., those that are sent via fetch, and not sendBeacon) retry every two seconds. The maximum number of re-tries is currently 2. Once both re-tries fail, the data is dropped.

With this change, PutRumEvents requests retry with exponential backoff, starting with two seconds and doubling every re-try thereafter. This means that the second re-try will happen after 4 seconds instead of after 2 seconds.