Storage
Every object that you add to your S3 bucket is associated with a storage class. All the available storage classes offer high durability. You choose how you want to store your objects based on your application’s performance access requirements.
At present, you can use the following storage classes with S3:
- STANDARD: default for frequently accessed data
- STANDARD_IA: for infrequently used data that needs to be retrieved rapidly when requested
- ONEZONE_IA: for the same use case as STANDARD_IA, but stores the data in one Availability Zone instead of three
- REDUCED_REDUNDANCY: for frequently used noncritical data that is easily reproducible
If you want to change the storage class of an existing object, you need to recreate the object.
00:00 At its heart, S3 is a storage service. To meet the needs of each project, it offers a number of storage classes to provide the performance required for each use case. Unlike changing the ACL for an object, if you want to change the storage class, you’ll need to recreate the object.
00:18
Let’s test this out on the third file that you used for encryption. Go ahead and grab that third_object
,
00:27 and we’re going to re-upload the file.
00:33
Pass in the third_file_name
and then also some ExtraArgs
.
00:45
Like before, add that 'ServerSideEncryption'
,
00:59
and then add another argument, which is going to be 'StorageClass'
.
01:07
So here, the storage class determines what type of storage your object will be stored in. You have a couple options. You can do something like 'STANDARD'
, and this is kind of your default for frequently accessed data.
01:22
If you have something that will be accessed infrequently, you can add an '_IA'
to that for infrequent access. This class is designed for things that would be used infrequently, but when they are used, they need to be retrieved rapidly.
01:38
The default for STANDARD_IA
is three availability zones at least, but if you only need one zone, you can change that to 'ONEZONE_IA'
.
01:50
And then finally, for something that’s frequently used but is non-critical and can be recreated easily, you can do a storage class that’s 'REDUCED_REDUNDANCY'
.
02:04
S3 also has Glacier storage now, which is geared towards long-term archiving. So, think of very infrequent access and not very rapid access. For this example, go ahead and re-upload this with 'STANDARD_IA'
. Close everything off, and that was successful! To verify that, you can reload the Object
instance with the most up-to-date version by saying third_object.reload()
, and this will just make the call to S3 to make sure that everything we have is up-to-date.
02:44
And now, you can say third_object
and access the .storage_class
property, and you can see that it is now 'STANDARD_IA'
.
02:57 Keep in mind that there are pricing differences and data retrieval times associated with each of these groups, so it can definitely help your project to review the specifics of each storage class so that you’re only paying for what you need to. AWS S3 also offers Lifecycle configurations to transition objects through different classes based on rules that you set. Once you’ve set these rules, objects will automatically transition through those classes for you.
03:26 This can be a good way to keep new data in a storage class that may be accessed more frequently, and then as that data becomes more of an archive, transition the class accordingly. All right!
03:39 Now that you have the handle on how to use different storage classes with S3, we’re going to talk about versioning your objects in the next video. See you there.
Become a Member to join the conversation.