S3 and MinIO in Practice: Object Storage for Data, Not a Giant Folder
A hands-on guide to S3 and MinIO for data: prefixes, consistency, lifecycle, versioning, permissions, costs, boto3, DuckDB, and Polars.
Table of Contents
You drag a 4 GB folder into the cloud and expect it to behave like the disk on your laptop. The next morning you try to rename it. The operation crawls, fails halfway, and leaves an orphaned prefix behind. That is the first lesson: object storage has no folders, only keys.
The difference sounds semantic until a data pipeline depends on it. A rename that is instant on Linux becomes a copy-and-delete of thousands of objects. append does not exist. A write of 200 files is not atomic. A reader can see half of yesterday’s dataset and half of today’s.
Understanding how S3 actually works, not how the console draws it, is the difference between a clean bucket and a surprise invoice.
The folder that never existed
When you see orders/dt=2026-12-05/part-000.parquet in the console, your brain draws a hierarchy. S3 does not have one. The bucket is a flat namespace, and the full key is the object name:
warehouse/orders/dt=2026-12-05/part-000.parquet
Slashes are ordinary characters. The console interprets them as separators so you can browse, but the service stores no directories. A prefix is just the beginning of a key. orders/ is a prefix because many keys start that way, not because a folder named orders exists.
That useful lie has consequences. Deleting “a folder” means deleting every object under that prefix, one by one. Renaming means copying every object to a new key and deleting the original. There is no atomic move for a whole tree. For a dataset, the prefix is the unit you list, partition, and authorize.
Buckets, objects, and prefixes
A bucket is the top-level container. For general purpose buckets, the name is globally unique within an AWS partition, lives in one region, and cannot be renamed. An object is identified by bucket, key, and, when versioning is on, a versionId.
| Concept | What it is | What it means for data |
|---|---|---|
| Bucket | Container and billing unit | Name and region are chosen once |
| Object | Bytes + metadata + key | Replaced whole, never edited in place |
| Key | Unique name inside the bucket | Up to 1,024 bytes, any character |
| Prefix | Leading part of the key | Organizes and filters, not a directory |
The ETag misleads people. For a simple PUT it usually matches the MD5, but for a multipart upload it is a hash of the parts. If you need integrity checks, use SDK checksums instead.
Listing has rules too. ListObjectsV2 returns at most 1,000 keys per call and uses a ContinuationToken to paginate. A script that calls it once and assumes it saw the whole prefix works in development and fails in production.
Consistency: what S3 guarantees and what it does not
S3 provides strong read-after-write consistency for PUT and DELETE requests. If a PUT succeeds, a later GET returns that data. Updates to a single key are atomic: a reader sees the old object or the new one, never a mix.
What does not exist is atomicity across keys. If you publish a dataset of 200 files, each PUT is independent. A reader listing the prefix while you write can see 80 new files and 120 old ones. Concurrent writers also race: two PUT requests to the same key, last one wins.
Bucket configuration is eventually consistent. After enabling versioning for the first time, AWS recommends waiting up to 15 minutes before writing. To publish a dataset without intermediate states, write to an immutable run prefix and publish a small manifest last:
{
"run_id": "2026-12-05T10:00:00Z",
"schema_version": "2.3.0",
"files": ["part-000.parquet", "part-001.parquet"],
"rows": 184223
}
The manifest PUT is atomic. Readers open it first, then the files it names. If it is missing, the partition is not published. The other option is a table format such as Iceberg or Delta, which handles the commit through its own metadata. A loose directory of Parquet files gives you neither guarantee.
Versioning and lifecycle: memory and forgetting
Versioning is off by default. When you enable it, every write creates a version and a DELETE inserts a delete marker instead of removing the object. Each version is billed as a full object. A versioned bucket cannot return to unversioned; you can only suspend it. Object Lock requires versioning.
Lifecycle moves objects to cheaper storage classes and expires what you no longer need. Rules apply to existing and new objects, and billing changes when an object becomes eligible, even if physical deletion takes longer:
import boto3
s3 = boto3.client("s3", region_name="us-east-1")
s3.put_bucket_versioning(
Bucket="warehouse",
VersioningConfiguration={"Status": "Enabled"},
)
s3.put_bucket_lifecycle_configuration(
Bucket="warehouse",
LifecycleConfiguration={
"Rules": [
{
"ID": "raw-tiering",
"Status": "Enabled",
"Filter": {"Prefix": "raw/"},
"Transitions": [
{"Days": 30, "StorageClass": "STANDARD_IA"},
{"Days": 90, "StorageClass": "GLACIER"},
],
},
{
"ID": "abort-incomplete-multipart",
"Status": "Enabled",
"Filter": {"Prefix": ""},
"AbortIncompleteMultipartUpload": {"DaysAfterInitiation": 7},
},
]
},
)
Two costs hide here. Archive classes have minimum storage durations: 30 days for Standard-IA, 90 for Glacier Flexible Retrieval, and 180 for Deep Archive. Delete earlier and you still pay the minimum. Multipart uploads that never finish also leave parts behind, and the abort rule cleans them up.
In a versioned bucket, expiring the current version only adds a delete marker. Noncurrent versions remain and keep costing money. Add NoncurrentVersionExpiration if you want them gone.
Permissions and encryption: the non-negotiable minimum
Buckets are private by default, and Block Public Access is on. Keep it that way unless you are intentionally serving a public site. IAM policies live on the user or role; bucket policies live on the bucket. They are evaluated together, and the most restrictive result wins. AWS recommends disabling ACLs.
The classic mistake is granting s3:GetObject on bucket/* and forgetting s3:ListBucket on the bucket. They are different permissions: one reads an object when you know the key, the other enumerates keys. To limit listing to a prefix, the condition goes on s3:prefix:
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "ListOnlyOrders",
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::123456789012:role/ingest-orders"},
"Action": ["s3:ListBucket"],
"Resource": "arn:aws:s3:::warehouse",
"Condition": {"StringLike": {"s3:prefix": ["orders/*"]}}
},
{
"Sid": "WriteOrders",
"Effect": "Allow",
"Principal": {"AWS": "arn:aws:iam::123456789012:role/ingest-orders"},
"Action": ["s3:PutObject", "s3:AbortMultipartUpload"],
"Resource": "arn:aws:s3:::warehouse/orders/*"
}
]
}
For encryption, S3 applies SSE-S3 by default to all new objects, at no extra cost, since January 5, 2023. SSE-KMS gives you key control and audit trails, but adds KMS costs and request quotas; enable S3 Bucket Keys if you choose it. Encryption at rest does not replace TLS.
Costs: the mental model that prevents surprises
S3 does not charge only for stored gigabytes. It charges for storage by class and month, requests, retrieval from archive classes, outbound transfer, and lifecycle transitions. A small dataset with millions of requests can cost more than a large one nobody reads.
| Driver | When it hurts | What to do |
|---|---|---|
| Storage | Data nobody deletes | Lifecycle and quarterly review |
| Requests | Many tiny files | Compact and batch reads |
| Transfer | Internet or cross-region egress | Process near the data |
| Versions | Versioning without cleanup | Expire noncurrent versions |
The cheapest pattern is boring: Zstd-compressed Parquet, reasonable file sizes, partitions that match query filters, and lifecycle for cold data. The most expensive one is also boring: thousands of 20 KB files and queries that list the whole bucket. Measure with S3 Storage Lens or Inventory before optimizing; without numbers, cost decisions are guesses.
Local MinIO with Docker, 2026 edition
MinIO was the standard way to get S3 locally. In 2026 the picture changed. MinIO stopped publishing community binaries and the repository is no longer maintained; the community edition is source-only now, and the supported option is AIStor, which requires a license even on its free tier.
For a lab, use the AIStor container with a free license. Download the file from min.io and save it as minio.license:
mkdir -p ./minio/data
docker run -d --name minio-lab \
-p 9000:9000 -p 9001:9001 \
-e MINIO_ROOT_USER=minioadmin \
-e MINIO_ROOT_PASSWORD=minioadmin \
-v "$PWD/minio/data:/mnt/data" \
-v "$PWD/minio/minio.license:/minio.license:ro" \
quay.io/minio/aistor/minio:latest \
server /mnt/data --license /minio.license --console-address ":9001"
The S3 API is at http://localhost:9000 and the console at http://localhost:9001. Create the bucket with mc alias set local http://localhost:9000 minioadmin minioadmin and mc mb local/warehouse. If you do not want a license dependency in CI, evaluate compatible alternatives such as Garage or SeaweedFS.
boto3: create, upload, list, and sign
boto3 is the most direct way to automate S3 from Python. For MinIO you change the endpoint, force signature v4, and use path-style addressing because the bucket is not a subdomain of localhost:
import boto3
from botocore.client import Config
s3 = boto3.client(
"s3",
endpoint_url="http://localhost:9000",
aws_access_key_id="minioadmin",
aws_secret_access_key="minioadmin",
region_name="us-east-1",
config=Config(signature_version="s3v4", s3={"addressing_style": "path"}),
)
s3.create_bucket(Bucket="warehouse")
s3.upload_file(
Filename="orders.parquet",
Bucket="warehouse",
Key="orders/dt=2026-12-05/part-000.parquet",
ExtraArgs={"ContentType": "application/vnd.apache.parquet"},
)
upload_file is not a naive PUT: it splits the file, uploads parts in parallel, and retries. For small files, put_object is simpler.
Listing requires pagination; a prefix with 50,000 objects does not fit in one response:
paginator = s3.get_paginator("list_objects_v2")
for page in paginator.paginate(Bucket="warehouse", Prefix="orders/"):
for obj in page.get("Contents", []):
print(obj["Key"], obj["Size"])
url = s3.generate_presigned_url(
"get_object",
Params={"Bucket": "warehouse", "Key": "orders/dt=2026-12-05/part-000.parquet"},
ExpiresIn=3600,
)
A presigned URL grants temporary access without sharing credentials. The signature expires and depends on the clock, so a server with drift produces URLs that fail. In production, use IAM roles or a secrets manager, never credentials in code.
DuckDB and Polars: read without copying
You can query data in S3 without downloading it to a local disk. DuckDB does it with httpfs and a secret that points at the endpoint:
INSTALL httpfs;
LOAD httpfs;
CREATE OR REPLACE SECRET minio_lab (
TYPE s3,
PROVIDER config,
KEY_ID 'minioadmin',
SECRET 'minioadmin',
ENDPOINT 'localhost:9000',
REGION 'us-east-1',
URL_STYLE 'path',
USE_SSL false
);
SELECT status, count(*) AS orders
FROM read_parquet('s3://warehouse/orders/dt=2026-12-05/*.parquet')
GROUP BY status
ORDER BY orders DESC;
DuckDB applies projection and predicate pushdown: if you only read status, it does not download the other columns. It also recognizes Hive-style dt=... partitions and uses the path values as columns.
Polars can read the same dataset through PyArrow, which is useful when you need a DataFrame instead of SQL:
import polars as pl
import pyarrow.dataset as ds
from pyarrow import fs
filesystem = fs.S3FileSystem(
endpoint_override="localhost:9000",
scheme="http",
access_key="minioadmin",
secret_key="minioadmin",
region="us-east-1",
)
orders = ds.dataset(
"warehouse/orders",
format="parquet",
filesystem=filesystem,
partitioning="hive",
)
result = (
pl.scan_pyarrow_dataset(orders)
.filter(pl.col("status") == "paid")
.group_by("dt")
.agg(pl.len().alias("orders"))
.sort("dt")
.collect()
)
The important call is scan_pyarrow_dataset, not read_parquet. The plan is built before materialization, and the optimizer pushes the filter and column selection into the read.
Partitioning patterns and file size
The right partitioning depends on the questions, not on aesthetics. If 90% of queries filter by date, partition by date. If they also filter by service, add that level. If they filter by order_id, do not partition by order_id: you would get millions of prefixes and tiny files.
warehouse/orders/
dt=2026-12-05/
part-000.parquet
part-001.parquet
dt=2026-12-06/
part-000.parquet
Target files of 128-512 MB. Under 50 MB creates metadata overhead and too many requests; over 1 GB limits parallelism. If ingestion produces many small files, add a compaction job.
Sort within each file by the column you filter most. Parquet keeps per-row-group statistics, and DuckDB or Polars can skip whole blocks when the range does not overlap. A file sorted by created_at enables time pruning; a randomly ordered one does not.
Prefixes do not spread S3 load the way many people assume: the slash has no special meaning. AWS documents roughly 3,500 PUT/COPY/POST/DELETE or 11,000 GET/HEAD requests per second per partitioned prefix, and it scales when you distribute keys. For pruning, prefixes still matter.
Common mistakes and checklist
- Treating S3 as a disk.
renamedoes not exist,appenddoes not exist, and deleting “a folder” deletes objects one by one. - Assuming a dataset publishes all at once. Without a manifest or table format, readers see intermediate states.
- Listing without pagination.
ListObjectsV2returns 1,000 keys per page; the rest exists and your script does not see it. - Creating millions of tiny files. Request costs grow faster than storage.
- Partitioning by high cardinality.
user_id=...as a partition is a factory of useless prefixes. - Leaving versioning without lifecycle. Every version is a full object and is billed.
Checklist before production:
- Bucket private and Block Public Access enabled.
- Least-privilege roles per team and prefix.
- Encryption at rest and TLS in transit verified.
- Keys documented (
dataset/dt=.../part-...). - Files at 128-512 MB or a scheduled compaction job.
- Readers use a manifest or a table format.
- Costs reviewed with Storage Lens or Inventory.
A bucket is not a giant folder. It is a namespace where every key, version, and lifecycle decision gets paid for, or appreciated, years later.
Related articles
By relevance
Data forensics in a factory: 18 months of files, one missing piece, and a lakehouse on your laptop
Hands-on case: date folders, nested blocks, movements, and logs. Unify, normalize, and trace a piece with DuckDB, Polars, and Parquet.
Parquet deep dive: a hands-on guide to the format behind the modern data stack
Hands-on Parquet guide: row groups, compression, partitions, metadata, Polars, DuckDB, and how to read large files with real speed.
Data Extraction, SQL & Automation in Go: Building Scalable Data Systems
Master data engineering in pure Go. Learn SQL querying, data extraction from multiple sources, transformation pipelines, automation workflows, and scientific data processing—all without external dependencies.
The modern data analytics stack in 2026: from giant Excel files to the AI-powered lakehouse
Informative guide to the 2026 data stack: DuckDB, Polars, Iceberg, Parquet, AI, log observability, and how to read large files fast.