“If objects are PUT using a multipart upload, it’s a good practice to GET them in the same part sizes (or at least aligned to part boundaries) for best performance.”
I had no idea, I figured that the part size in a multipart upload only mattered for the upload. It turns out it also matters for any time you fetch the object afterwards, and performance is negatively impacted by fetching ranges that span the boundaries of your initially uploaded parts.
Is there any way to cause S3 to “re-partition” these parts?
I know of only one way, which is to transition an object to Glacier Deep Archive then restore it. That forces the object to be repackaged into 2^24 byte parts, which you can determine by looking at the ETag, which is recalculated. So it is possible, at least in one way. Is there a more practical way?
This is interesting, as s3 put will automatically multipart large files for efficiency and it implies this will be 8 or 16mb depending on the size of the file.
It seems you only indirectly control the part size by specifying the number of parts when you use low-level s3api commands for the multipart - no apparently restriction there except for a minimum of 5mb per part. How you would latterly know you did this when you come to download (so you could at least specify the correct byte-range), I’m not sure.
Let me know if you figure this out - curious one I’ve not encountered before.
Interesting to know. This implies that S3 doesn’t bother to stitch up the parts after they are uploaded, but instead just save the parts individually. And the parts are likely not saved together physically either, which is why retrievals spanning parts need to take more time.
I’m not sure practically we need to worry about the performance overhead though. The transmission time from S3 back to the client likely still dominates.
As someone who works at a smaller cloud provider, s3 like implementation are also subject to those constraints (parts kept as is, and incomplete multipart upload taking up space)
There’s no way to “repartition” aside from downloading and re-uploading using a different layout.
Someone mentioned the min limits, but here’s the max:
1000 parts maximum
5gb max per part
Which means that you can “only” upload files up to 5tb.
You can create an S3 Event Notification that calls a lambda that would do an get/put. You do have to be careful of an infinite execution loop on calling put.
There is an s3:ObjectCreated:CompleteMultipartUpload trigger that should avoid the execution loop. Other options to avoid the execution loop are to upload to a prefix or a separate bucket.
I know of only one way, which is to transition an object to Glacier Deep Archive then restore it. That forces the object to be repackaged into 224 byte parts, which you can determine by looking at the ETag, which is recalculated.
This doesn’t sound right. Where did you find this behavior documented? If you’re using lifecycle to transition the object, and the RestoreObject API to restore it, the ETag shouldn’t change.
If the etag changes that means the contents changed. Also moving into and out of glacier will add cost and if your files are small that cost can get out of hand really fast. There is also a minimum object lifetime in glacier that you’ll be on the hook for.
If the etag changes that means the contents changed.
Sorry, not true! The ETag depends on the part size. It is the MD5 of each part, concatenated and MD5’d again. So if you upload the exact same file at two different part sizes, you will get different ETags. And if you upload a file at the default part size (5MB) then move it to glacier deep archive, the ETag will be recalculated at a part size of 16MB even though the contents did not change.
It’s true. Try it. Upload a file, let’s say 8 megabytes, using the AWS CLI. The ETag will end in -2 meaning “two parts” (because the default is a 5MB part size). Move it to Glacier Deep Archive. The ETag will be recalculated and now will no longer end in -2 because now it’s just one part.
Where did you find this behavior documented?
I did not, I figured this out by trial and error. I have a program that backs up files to S3. I wrote a utility that makes sure that the remote ETag is the same as what it is expected to be locally, and I noticed that the ETag changed whenever the storage class changed. By guesswork and assuming it would be a power of two, I determined the part size in Glacier Deep Archive is always exactly 16777216 bytes. It also helps that the number after the hyphen in the ETag tells you how many parts it is.
If you’re using lifecycle to transition the object, and the RestoreObject API to restore it, the ETag shouldn’t change.
¯\(ツ)/¯
I too would love it if this were true. It would be very convenient. But it isn’t!
Ah. If you’re changing the storage class outside of lifecycle, you’re actually copying the object on top of itself with the new storage class. You’ll notice there isn’t any API for changing the storage class. If you use the CopyObject API, it doesn’t preserve the existing part structure. The console leads you to believe you’re editing the storage class on an object but that isn’t really true, it’s just calling the copy api.
Note that you don’t need to change the storage class to achieve this.
No, I changed the storage class using a lifecycle rule.
Tell me I’m wrong and it “doesn’t sound right” all you like, but it really does happen lol. Upload a 8mb file in two parts, have a lifecycle rule transition it to Deep Archive. When that happens, the ETag will change.