Skip to content

Instantly share code, notes, and snippets.

@iamricks
Created December 16, 2022 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iamricks/22ce4b05637a364f4b384b8acdd6fd67 to your computer and use it in GitHub Desktop.
Save iamricks/22ce4b05637a364f4b384b8acdd6fd67 to your computer and use it in GitHub Desktop.
Endpoint Faliure Rate Calculator
# This script helps calculate the total number of requests given a failure rate
# Example: 1,000,000 requests with a 33% failure rate will result in 492,536 retries
# This means it would take 1,492,536 requests to update 1M objects in an endpoint
# that has a 33% failure rate.
total_retries = 0
requests = 1_000_000
faliure_rate = 0.33
attempt = 1
while requests > 3 do
retries = requests * faliure_rate
requests = retries
total_retries += retries
puts "On the #{attempt} attempt, #{(retries).to_i} will be retried!"
attempt += 1
end
puts "Total retries: #{total_retries.to_i}"
@iamricks
Copy link
Author

This can help you calculate the needed throughput for an endpoint given an average failure rate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment