Skip to content

Retry on rate limiting - #620

Merged
martindurant merged 2 commits into
fsspec:mainfrom
ian-r-rose:retry-on-rate-limiting-errors
May 4, 2022
Merged

martindurant merged 2 commits into
fsspec:mainfrom
ian-r-rose:retry-on-rate-limiting-errors

Conversation

@ian-r-rose

Copy link
Copy Markdown
Contributor

This treats ResponseParserErrors as retryable, as well as ClientErrors if they contain SlowDownin the message. This can mitigate/fix #484, and is a non-mutually-exclusive alternative to #619. Where that PR tries to address rate limiting at the request time, this tries to address it in the responses.

In my testing with the snippet here, this helps a lot, but is not a complete fix, as I still often exhaust the default retries. So I might be in favor of both this and #619 (or something similar to it based on asyn._run_coros_in_chunks)

@ian-r-rose
ian-r-rose force-pushed the retry-on-rate-limiting-errors branch from 20d54c0 to c0f6d8e Compare April 29, 2022 21:52
@ian-r-rose

Copy link
Copy Markdown
Contributor Author

Okay, I've also added _run_coros_in_chunks to accomplish a similar batching to what I did in #619. This appears to work to avoid rate limiting even in the absence of the built-in minimum times that I added over there. So if it would be simpler to consolidate that logic, I'm happy with this approach.

Comment thread s3fs/core.py
sync,
sync_wrapper,
FSTimeoutError,
_run_coros_in_chunks,

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love this private import, so I'm given to just vendor this function over here. What do you think @martindurant?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could even expose it as a public function directly from fsspec.

@ian-r-rose

ian-r-rose commented Apr 30, 2022 via email

Copy link
Copy Markdown
Contributor Author

@martindurant

Copy link
Copy Markdown
Member

S3fs is sister to and closely tied to fsspec - they are always released together. I prefer to keep the function "private" to indicate that ordinary users would not be expected to call it.

@ian-r-rose

Copy link
Copy Markdown
Contributor Author

Yep, I’m aware they’re both released by you :)

If you’re okay with the cross-repo private import, then I am as well

Comment thread s3fs/core.py
for i in range(0, len(files), 1000)
]
],
batch_size=3,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this batch size come from? I would have thought it could be a much bigger number.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This comes from two places:

  1. A rough attempt to stay under 3500 deletes per second. Despite the fact that those docs describe concurrent HTTP requests (rather than object deletes), I found it was pretty easy to hit with this batched approach as well.
  2. Some experimentation. When I made this as high as ~5-6, I started to see rate limiting with my example in the linked issue.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this value, how long did it take to delete ~1000 keys or more?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the context of many dask tasks doing the same in parallel?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in the context of many dask tasks doing the same in parallel?

No, this is in the context of a bulk delete from a single S3FileSystem instance. That occurs in a dask Client when overwrite=True, but can reproduced by itself as per #484 (comment)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So if we are submitting just 3 at a time, then to get to 3500, these must come back in about 1ms, right? I didn't think you could go that fast even in the right AWS region. Now we have the tricky problem that the "best" number will depend on where this is called from.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these must come back in about 1ms, right?

I think they come back in ~1s, but are batched into bulk delete calls of 1000 keys.

Now we have the tricky problem that the "best" number will depend on where this is called from.

Yeah, it's tough to come up with a "best" number. That's what I was attempting to do in #619.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Of course, so sorry - these are thousands of deletes! Please ignore my hesitation in that case. It totally makes sense to send ~3000 requests and wait for them all to end before sending more.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just re-ran my testing scripts with some timing information -- in my case each 1000-key bulk delete took 1-2 seconds, though I don't know how reproducible that is in other contexts.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@martindurant

Copy link
Copy Markdown
Member

@isidentical , I'm happy with this if you don't have more to say.

@isidentical isidentical left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me.

@martindurant
martindurant merged commit 2a53f0f into fsspec:main May 4, 2022
@ian-r-rose

Copy link
Copy Markdown
Contributor Author

Thanks @martindurant!

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

XML parsing error when trying to delete lots of objects on s3

3 participants