You can configure lifecycle rules for an Object Storage Service (OSS) bucket based on the last access time of the objects in the bucket. After you configure a lifecycle rule for a bucket, OSS monitors the access patterns of the objects in the bucket, identifies cold data, and converts the storage class of cold data. This way, cold data and hot data are stored by using different storage classes, and storage costs are reduced.
Scenarios
Multimedia
After you store videos and images of your website in an OSS bucket, some of the data may become infrequently accessed over time. For data that becomes infrequently accessed, you may need to convert the storage class to Infrequent Access (IA). For data that was uploaded a long time ago but is still frequently accessed, you need to retain the Standard storage class. You can configure a lifecycle rule for the bucket based on the last access time of the objects in the bucket. This way, cold data and hot data are stored by using different storage classes, and storage costs are reduced.
Albums or network disks
You can configure a lifecycle rule based on the last access time for a bucket that is used to store albums or used as a network disk. Then, the storage class of cold data is automatically converted to IA after the lifecycle rule is triggered, and the data can be accessed in real time.
Life science
A large amount of data is generated in gene sequencing. In most cases, whether the data is frequently accessed is determined based on the last access time instead of the last modified time of the data. You can manually implement tiered storage of cold and hot data based on log analysis or other methods. A more efficient method for tiered storage is to use a lifecycle rule based on the last access time, which allows OSS to automatically identify cold and hot data and store data in appropriate storage classes. You can also specify policies based on the last access time and the last modified time in the same lifecycle rule to manage data in a more flexible manner.
Limits
Data deletion
You cannot delete data by using lifecycle rules that are based on the last access time.
Match conditions
Currently, lifecycle rules support only matching based on prefixes and tags. Wildcard matching, suffix matching, and regular expression matching are not supported.
Part lifecycle
You cannot configure two or more lifecycle rules that contain a part lifecycle policy for objects whose names contain overlapping prefixes. Examples:
- Example 1
If you configure a lifecycle rule that contains a part lifecycle policy for a bucket, you cannot configure another lifecycle rule that contains a part lifecycle policy for objects whose names contain any prefix in the bucket.
- Example 2
If you configure a lifecycle rule that contains a part lifecycle policy for objects whose names contain the dir1 prefix in a bucket, you cannot configure another lifecycle rule that contains a part lifecycle policy for objects whose names contain overlapping prefixes, such as dir1/dir2.
Usage notes
Number of lifecycle rules
You can configure up to 100 lifecycle rules in the OSS console. You can also specify policies based on the last access time and last modified time in the same lifecycle rule. If you want to configure more than 100 lifecycle rules, use OSS SDKs or ossutil.
Fees
Object monitoring and management fees
After you enable access tracking for a bucket, object monitoring and management fees are generated. However, you are not charged the fees.
Storage fees for IA objects that are stored for less than the minimum storage duration
IA objects have a minimum storage duration of 30 days. You are charged for the entire minimum storage duration of IA objects if the IA objects are stored for less than the minimum storage duration. The following examples show how IA objects are billed when you configure lifecycle rules based on the last access time of the objects:
Example 1: OSS converts a Standard object to an IA object 10 days after the object is created and converts the IA object back to a Standard object after 5 days based on the configured lifecycle rule. In this case, you are also charged for the remaining 15 days.
Example 2: OSS converts a Standard object to an IA object 10 days after the object is created and deletes the IA object after 15 days based on the configured lifecycle rule. In this case, you are also charged for the remaining 5 days.
For more information, see Storage fees.
Retrieval fees for IA objects
When you access IA objects, you are charged data retrieval fees based on the size of the retrieved IA objects. For more information, see Data processing fees.
API operation calling fees
When you convert storage classes of objects by using lifecycle rules, you are charged API operation calling fees. For more information, see API operation calling fees.
Overwrite semantics
The PutBucketLifecycle operation overwrites the existing configurations of a lifecycle rule that is configured for a bucket. For example, if a lifecycle rule named Rule1 is configured for a bucket and you want to configure a lifecycle rule named Rule2 for the bucket based on Rule1, perform the following operations:
- Call the GetBucketLifecycle operation to query Rule1.
- Configure Rule2 for the bucket based on Rule1.
- Call the PutBucketLifecycle operation to update the lifecycle rule configurations of the bucket. In this case, Rule1 and Rule2 are configured for the bucket.
Effective time
After you configure a lifecycle rule, OSS loads the rule within 24 hours. After the lifecycle rule is loaded, OSS runs the rule every day at 08:00:00 (UTC+8).
Completion time
For a lifecycle rule that does not contain tags, OSS can complete up to 1 billion lifecycle management operations (such as storage class conversion and part expiration) within 24 hours based on the lifecycle rule. If the number of lifecycle management operations based on the lifecycle rule exceeds 1 billion, the time required to complete the operations may exceed 24 hours.
For a lifecycle rule that contains tags, OSS can complete up to 500 million lifecycle management operations (such as storage class conversion and part expiration) within 24 hours. If the number of lifecycle management operations based on the lifecycle rule exceeds 500 million, the time required to complete the operations may exceed 24 hours.
Policies for updating the last access time
After you turn on Enable Access Tracking for a bucket on the Lifecycle page, the initial last access time of all objects in the bucket is set to the time when access tracking is enabled. If multiple GetObject requests are sent to access the same object within 24 hours, the last access time of the object is set to the time when the object is accessed by the first GetObject request. If other requests, such as PutObject and CopyObject requests, are sent to access an object, the last access time of the object is updated per request.
For more information about the operations that update the last access time of an object, see Which operations update the last access time of an object?
Supported storage classes
You can use a lifecycle rule based on the last access time of objects to convert the storage class of the objects from Standard to IA and specify whether to convert the storage class of the objects from IA to Standard after the objects are accessed.
You can use a lifecycle rule based on the last access time of objects to convert the storage class of the objects from Standard or IA to Archive or Cold Archive and from Archive to Cold Archive. If you want to convert the storage class of objects from Standard or IA to Archive or Cold Archive, submit a ticket to apply for the required permissions. After the application is approved, you must specify the storage class to which you want to convert the objects.
ImportantAfter the application is approved, if you configure a lifecycle rule based on the last access time of objects for a bucket to convert the storage class of the objects in the bucket from Standard or IA to Archive or Cold Archive, the last access time of the Archive or Cold Archive objects in the bucket is the time when access tracking is enabled for the bucket.
Configure a lifecycle rule for a bucket for which OSS-HDFS is enabled
To configure or modify a lifecycle rule to match all objects in a bucket for which OSS-HDFS is enabled, use the NOT element to exclude the objects that are stored in the .dlsdata/
directory. This prevents storage class conversion operations that are triggered by the lifecycle rule from affecting data read and write operations on OSS-HDFS data.