CodePark/ questions / S3 & object storage
START PRACTICINGPRACTICE
Backend question · Cloud & AWS › S3 & object storage

What are S3 storage classes, lifecycle rules and versioning, and how would you use them for user uploads and logs?

Storage classes set the price and speed of storing data. Lifecycle rules move or delete objects automatically. Versioning keeps old copies of objects.

Storage classes trade the storage price against the cost and speed of reading data back:

  • S3 Standard is for data you read often.
  • Standard-IA (Infrequent Access) is cheaper to store, but you pay each time you read data.
  • Glacier classes are for archives. Some of them make you wait before you can read the data.
  • Intelligent-Tiering moves objects between tiers automatically, based on how often you read them.

Lifecycle rules act on objects based on their prefix or tag and their age. They can:

  • Move objects to a cheaper class.
  • Expire (delete) objects.
  • Delete old noncurrent versions (versions that a newer one replaced).
  • Abort multipart uploads that never finished.

Versioning keeps every version of an object. So you can undo an overwrite or a delete. When you delete an object, S3 adds a delete marker instead of removing the data.

For user uploads: turn on versioning, and expire noncurrent versions after some days.

For logs: move them to an archive class after a month. Expire them at the end of your retention period (how long you must keep them).

  • Storage classes trade storage cost against the cost and speed of reading data.
  • Intelligent-Tiering moves objects between tiers based on how often you read them.
  • Lifecycle rules move, expire and clean up objects by prefix, tag and age.
  • Versioning protects you against overwrites and deletes.
  • Expire noncurrent versions, so versioning does not grow your costs forever.