dotnet / orleans

Cloud Native application framework for .NET
https://docs.microsoft.com/dotnet/orleans
MIT License
10.37k stars 2.07k forks source link

AWS S3 Storage Provider #9449

Open seniorquico opened 3 weeks ago

seniorquico commented 3 weeks ago

AWS S3 now supports conditional writes using the If-None-Match and If-Match + ETag request headers:

https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-requests.html

As a looong follow-up to #6428... I'd be happy to prototype, test, and contribute an implementation. Is there interest in a PR to the core repo, or would this be better as an OrleansContrib package?

ReubenBond commented 3 weeks ago

I am interested in this and having it in the core repo as long as we have an emulator for it in GitHub Actions. My understanding is that S3 doesn't let you overwrite an existing blob yet. Do you have ideas on how to implement updates?

seniorquico commented 3 weeks ago

I am not aware of any issues with overwriting/updating blobs- but maybe there are some assumptions to lay out? I'm thinking of an implementation with a single PutObject call, not multi-part uploads. The docs seem to indicate multi-part uploads support conditional writes, as well. I don't have any experience with it, though. A single PutObject call would limit the total size of the grain state. I have to admit, it's not a concern for our specific use case. If this disqualifies it for contributing to core, I would understand.

A few years ago, AWS introduced strong read-after-write consistency. (That was another challenge with trying to use it as a storage provider.) That, combined with the conditional writes, I believe S3 is viable as a storage provider? I threw together this quick gist to test the conditional write behavior simulating concurrent writes based on ETags:

https://gist.github.com/seniorquico/e6e2d7616b599846d1f177a6f9782192

It's (obviously) not a high performance test to force race conditions server-side. That said, I tested with AWS S3, Cloudflare R2, and Min.io, and it worked as expected. (Cloudflare R2 and Min.io supported conditional writes before AWS S3.)

I'll have to do some research into emulator options for GitHub Actions and whether or not any support the conditional write behaviors.

ReubenBond commented 3 weeks ago

Ok, this is great - I was mistaken. I see the updated docs on the behavior here: https://docs.aws.amazon.com/AmazonS3/latest/userguide/conditional-requests.html

seniorquico commented 2 weeks ago

FYI- We have an internal prototype, and we're planning out integration and load tests. We'll share a PR for feedback when we're confident in the approach.