frumos
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 working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
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
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #ai
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
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.