Closed 4141done closed 7 months ago
/dev_build
/build_dev
Build and Push Dev Preview Image The long task is done!
You can find the workflow here: https://github.com/nginxinc/nginx-s3-gateway/actions/runs/8058196483
The general gist of the PR looks good to me! Some thoughts re your open ended questions --
Do we want to be able to control the slice cache separately from the main cache?
I see the sliced cache as an additional feature of the main cache so as a user, I don't think you'd need to control the sliced cache separately. In so far as an NGINX implementation detail goes, a separate cache might help fine tune the necessary slice cache settings (but I would still consider using the same cache until such a point comes).
Do we need to disable proxy_cache_lock in the slice-cached handler?
My go to would be to use a default value at which proxy_cache_lock
gets enabled for both normal and sliced requests, yet allow the user to tweak that value.
Do we necessarily need to separate the cache storage on disk?
I think this should be the default. I can see slicing back together the data on disk being useful for some use cases, but doing so should be an optional toggle.
Sorry @alessfg for the thumbs down. I have a rampant bot that I had to fix. Thank you for your comments, I'm take them into account as we work on this feature more.
What
A potential fix for #188
When the
Range
header is supplied:PROXY_CACHE_SLICE_SIZE
until the requested range is satisfiedPROXY_CACHE_SLICE_SIZE
.When the
Range
header is not supplied:proxy_cache_lock
ensures that multiple requests for the same file are not cached multiple times. Requests received after the initialMISS
will queue until they can be served from the cache (the initial request cache write is complete).I think it's good to have the ability to serve and cache byte range requests efficiently by default. Although we could turn this on and off with a config option, the overhead is low and makes the gateway more flexible.
Implementation Details
This solution takes advantage of the existing redirectToS3 function to change the target NGINX conf location based on the presence of the
Range
headerThe main configuration for the s3 proxy action has been broken out into
common/etc/nginx/templates/gateway/s3_location_common.conf.template
A separate cache is defined for the slice-based caching
In the slice caching location, the http_slice_module is configured and other caching options overridden as necessary.
Open questions:
@s3_sliced
location?Examples
Normal Request
A single cache file is created
The size of the cache file is equal to the requested file:
Byte Range Request
In this example, I'm requesting a 5mb file, and the
PROXY_CACHE_SLICE_SIZE
option has been set to1000k
(1000 kilobytes)Cache files are created in chunks:
The size of each cache file is roughly equal to the requested file the chunk size: