Data access frequency decreases over time. Lifecycle management lets you create rules that automatically transition objects to lower-cost storage classes (such as Infrequent Access or Archive) or delete them after a specified period, reducing storage costs without manual intervention.
How it works
Lifecycle management uses user-defined rules to automate operations on objects in a bucket. OSS loads a new rule within 24 hours of creation. After loading, OSS executes matching rules at a fixed time daily, typically after 00:00 (UTC) the next day (08:00 UTC+8).
A lifecycle rule consists of three main parts:
-
Objects to manage: Filter target objects by object prefix (Prefix), object tag (Tag), or object size (ObjectSize).
Lifecycle rules do not support wildcard characters, suffix matching, or regular expressions.
-
Actions to perform: Define what to do with filtered objects:
-
Storage class transition (Transition): Transition objects to lower-cost storage classes such as Infrequent Access, Archive, or Cold Archive.
-
Expiration and deletion (Expiration): Delete objects after they reach a specified lifecycle period.
-
Fragment cleanup (AbortMultipartUpload): Automatically delete parts from incomplete multipart uploads after a specified time.
-
-
Trigger policies: Define when actions trigger:
-
Last modified time (Last-Modified-Time): Transition or delete objects based on last modified time. Suitable for data with a clear lifecycle, such as logs and backups.
-
Last access time (Last-Access-Time): After enabling access tracking, transition objects based on last access time. Suitable for unpredictable access patterns (such as a material library). Cold data is downgraded automatically and restored on access.
-
All configurable parameters are documented in Lifecycle configuration elements.
Configuration scenarios
Automatically clean up expired log files
Servers upload logs daily to a designated directory. Use a last-modified-time rule to delete all objects in a bucket after a specified number of days, releasing storage and reducing costs.
Use automatic storage tiering for hot and cold data
For data with uncertain access frequency (website images, videos, documents), enable access tracking and use a lifecycle rule based on the last access time to implement intelligent data tiering. The system transitions cold data to lower-cost storage classes based on actual access patterns.
Automatically clean up previous versions
With versioning enabled, overwrites and deletes are saved as previous versions. When a bucket accumulates many previous versions or expired delete markers, use a lifecycle rule based on the last modified time together with versioning to reduce storage costs. This reduces costs and improves object listing performance.
Automatically clean up fragments from multipart uploads
Interrupted multipart uploads leave unmerged parts that continue incurring charges. Configure a lifecycle rule to clean up incomplete parts after a specified time.
In addition to the preceding scenarios, you can implement more fine-grained data management policies. For more information, see Lifecycle configuration examples. You can combine different rules to achieve fine-grained management of data in your bucket as needed.
Multiple lifecycle rules
Multiple lifecycle rules rely on two mechanisms: rule execution priority and the configuration overwrite mechanism.
Rule execution priority
A bucket can have multiple independent lifecycle rules. When an object matches multiple rules, the final action is determined by all matching results.
When multiple rules match the same object at the same time, they are executed in the following order of priority: Delete Object > Transition to Deep Cold Archive > Transition to Cold Archive > Transition to Archive > Transition to Infrequent Access > Transition to Standard.
The delete action always has a higher priority than storage class transitions. Set the time for delete rules to be longer than the time for transition rules. This prevents objects from being deleted before the transition is complete.
Execution example
Assume you specify the following two lifecycle rules, and both rules match the same object.
-
Rule 1: Specifies that objects last modified more than 365 days ago are transitioned to the Infrequent Access storage class.
-
Rule 2: Specifies that objects last modified more than 365 days ago are deleted.
Result: The object that matches the rules will be deleted more than 365 days after its last modification time.
Configuration overwrite mechanism
The console handles merging automatically, preventing accidental overwrite. However, when using ossutil, SDKs, or the API, each PutBucketLifecycle call completely overwrites all existing lifecycle configurations. Submitting a new rule without including existing ones deletes those rules.
Example
If you want to add a new rule to your existing rules, perform the following steps:
-
Retrieve all currently effective lifecycle rules (for example, Rule 1).
-
Add the new rule (for example, Rule 2).
-
Resubmit the complete configuration that includes all rules (Rule 1 + Rule 2).
Note: If you submit only the configuration containing the new rule (Rule 2) without including the existing rule (Rule 1), Rule 1 will be deleted and will no longer be effective.
Going live
To deploy lifecycle management safely in production:
-
Test before you deploy: Create rules in a test bucket first. Verify behavior before applying them to production.
-
Use delete rules with caution: Set the prefix precisely to prevent accidental deletion of important data.
-
Enable versioning as a safeguard: For critical data, enable versioning so that objects accidentally deleted by a lifecycle rule can be recovered from a previous version.
-
Use tiered transitions to avoid extra fees: Ensure the trigger time for each subsequent stage exceeds the sum of the previous stage's trigger time and its minimum storage duration. This avoids fees from premature transitions.
-
Incorrect example: Standard
30 days-> Infrequent Access40 days-> Archive Storage. The object stays in IA for only 10 days (< 30 days) before transitioning again, incurring a fee. -
Correct example: Standard
30 days-> Infrequent Access90 days-> Archive Storage. The object stays in IA for 60 days (meeting the 30-day minimum) before transitioning to Archive at day 90.
-
Billing
Configuring lifecycle rules is free. Fees apply when rules execute and change storage state.
-
Request fees: Each storage class transition, object deletion, or part deletion generates a
Put-type request. Fees are charged per request. Billing details are in Lifecycle fee description.For buckets with many small files, request fees can be significant. Evaluate before configuring rules.
-
Storage fees: After transition, objects are billed at the new storage class rate.
ImportantStorage classes such as Infrequent Access, Archive, and Cold Archive have minimum storage duration requirements (for example, 30 days for Infrequent Access and 60 days for Archive). If a lifecycle rule deletes or transitions an object before the minimum storage duration is met, you must pay for the remaining storage duration. To avoid conditional capacity fees for storage shorter than the specified duration due to transitions or deletions, see How do I avoid capacity fees for storage shorter than the specified duration?. Ensure that the minimum storage duration is met before transitioning or deleting.
-
Data retrieval fees: Lifecycle rules themselves do not incur data retrieval fees. However, accessing objects in storage classes such as Infrequent Access or Archive incurs retrieval fees.
-
Reading an IA object directly incurs data retrieval fees.
-
Reading an Archive object incurs data retrieval capacity fees for real-time access.
-
Restoring an Archive object incurs Put-type request fees and retrieval capacity fees.
-
Restoring a Cold Archive or Deep Cold Archive object incurs retrieval request fees, retrieval capacity fees, and temporary restored capacity fees.
ImportantFor Cold Archive and Deep Cold Archive objects, the fee varies depending on the retrieval priority you choose. A higher priority results in a higher fee.
-



