frumos
How do I retry throttled S3 puts
Hello Elixir community!
I have an issue that S3 throttles my requests and app eventually fails.
This is a function uploading stuff and been throttled by S3
def upload_file(bucket, object_key, file_path) do
Logger.info("Upload file: #{file_path} to: #{object_key}")
file_path
|> ExAws.S3.Upload.stream_file()
|> ExAws.S3.upload(bucket, object_key,
# 240 sec
timeout: 240_000
)
|> ExAws.request!()
object_key
end
This is S3 response:
** (EXIT from #PID<0.1257.0>) shell process exited with reason: an exception was raised:
** (ExAws.Error) ExAws Request Error!
{:error, {:http_error, 503, "<Error><Code>SlowDown</Code><Message>Please reduce your request rate.</Message><RequestId>A982186D97E156DC</RequestId><HostId>gZCe7g1Hat41iziw8NYDK8K1Wz9WoHEPpq1DrNv9bVAqDB4Mh+beKYXjE8BMqPPgjeCOnSZ9unQ=</HostId></Error>"}}
(ex_aws 2.1.3) lib/ex_aws.ex:66: ExAws.request!/2
(kona 0.1.0) lib/remo3/aws_s3.ex:38: Remo3.Aws.S3.upload_file/3
(kona 0.1.0) lib/remo3/account.ex:103: Remo3.Importer.Account.finalize_account_file/3
(elixir 1.10.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(elixir 1.10.3) lib/task/supervised.ex:35: Task.Supervised.reply/5
(stdlib 3.11) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
this is ExAws config:
config :ex_aws, :retries,
max_attempts: 30,
base_backoff_in_ms: 30,
max_backoff_in_ms: 60_000
Could you suggest please how can resolve the issue by continue retrying until success? What is missed in my implementation for that?
Thank you.
PS: My S3 partition schema is in good shape and been reviewed by S3 team.
Trending in Questions
I’m in search of an Elixir library that offers PDF generation capabilities similar to Ruby’s Prawn. While there have been discussions abo...
New
I’m looking to build a personal workflow to quickly deploy web applications written in elixir/phoenix, for local consumption (ie not on t...
New
Using Phoenix.LiveView.TagEngine as an EEx.Engine is deprecated!
To compile HEEx, use Phoenix.LiveView.TagEngine.compile/2 instead.
Sta...
New
Before I dive in myself, did anyone successfully sprinkle Hologram into their existing LiveView app?
Looking for hints regarding:
Addi...
New
Hi all, I wanted to ask how the community is dealing with post-release steps.
Today we have Ecto migrations, which make sure that the db...
New
I am using Oban and occasionally, shortly after a deployment, a handful of jobs can fail because of dependency on other parts of the syst...
New
Hello,
I have an Elixir backend that implements a custom protocol over TCP. I want to load test the backend and assess the performance o...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Emily is an Elixir library that runs Nx computations on Apple’s MLX. Install it as the default Nx backend and Nx, defn, Axon, Nx.Serving,...
New
I just stumbled on a newly redesigned elixir-lang.org. :tada: It looks like @Software_Mansion did the work, and I think it is generally a...
New
@hugobarauna and I (Alex Koutmos) have been hard at work on writing a book on Nerves that takes you from simply blinking LEDs to building...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #elixirconf-us
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #performance










First 7 of 7 Posts
NobbZ
You need to rate limit your calls to
uploaf_file/3.You seem to be calling it beyond your allowed rate.
There are several ways to do so and do depend on how you are using the function.
frumos
Sorry I just need to persist to retry … my rate is far less that capabilities of S3 (this has been already discussed internally according to this: Best practices design patterns: optimizing Amazon S3 performance - Amazon Simple Storage Service)
The reason S3 throttles is that it detect it as anomaly burst with internal mechanism. So my goal is to get retry logic in shape. Thank you.
NobbZ
If it’s detected as an abnormal burst, you need to limit the rate with which you try to upload.
Just retrying more often will not solve the issue. It will just make it worse, as it even adds more and more requests.
frumos
Sorry I just need to retry with exponential backoff and this strategy to my understanding comes out of the box here: ExAws — ExAws v2.7.0 but i am not sure if it even works. At least I see no any actions in the log for that.
kip
@NobbZ is suggesting that any back off strategy is not going to produce optimism throughput and may in fact contribute to you getting rate limited messages because you will likely make the “burst” behaviour more prevalent as detected by AWS.
Using a rate limiter will maximise request throughput, create a much more event workload for AWS and therefore reduce the change you get rate limited (according to whatever AWS decides your rate should be).
Using a rate limiter with Elixir (and Phoenix if required) is quite easy. This article might be a good place to start.
ChrisYammine
Try using the non-bang variant of the request function
ExAws.request/2and then match on success/rate limit/failurekaashyapan
You could try spreading out or randomising your prefixes in the object key.
AWS applies rate limitations at the prefix level as well.