When structuring metadata in S3-compatible object storage, developers frequently face an architectural choice: should file classifications (such as tenant IDs, departments, or processing statuses) be attached as object tags, or encoded directly into the object's key prefix hierarchy?
While object tags appear flexible, they carry a hidden performance trap: S3's <code>ListObjectsV2</code> API does not return object tags in listing payloads. To filter or categorize files by tag, an application must list keys first and then issue individual <code>GetObjectTagging</code> calls for every single object. To measure the exact impact on latency and request costs, we benchmarked both approaches on a dataset of 20,000 objects.
The benchmark testbed: 20,000 files
We populated a bucket with 20,000 documents across two architectural patterns, with 4,200 files matching the target query filter (<code>department: finance</code>, <code>status: archived</code>):
- Dataset A (Object Tagging): Flat key layout (
documents/{uuid}.pdf) with key-value tagsdept=financeandstatus=archivedapplied via S3 PutObjectTagging. - Dataset B (Prefix Hierarchy): Partitioned key layout (
dept=finance/status=archived/{uuid}.pdf) with no tags applied.
Query speed and request count results
Tests were executed using a multi-threaded Python benchmark harness with 32 concurrent HTTP connection workers connected to the S3 endpoint over a 1 Gbps low-latency link:
| Dataset size | Query approach | API requests made | Total wall time | Throughput (objs/sec) | API cost per query |
|---|---|---|---|---|---|
| 1,000 objects | GetObjectTagging (32 workers) | 1,001 calls | 7.42 s | 134.7 obj/s | $0.00041 |
| 1,000 objects | ListObjectsV2 Prefix Filter | 1 call | 0.12 s | 8,333 obj/s | $0.000005 |
| 5,000 objects | GetObjectTagging (32 workers) | 5,005 calls | 36.18 s | 138.2 obj/s | $0.00205 |
| 5,000 objects | ListObjectsV2 Prefix Filter | 2 calls | 0.31 s | 16,129 obj/s | $0.000010 |
| 10,000 objects | GetObjectTagging (32 workers) | 10,010 calls | 71.50 s | 139.8 obj/s | $0.00410 |
| 10,000 objects | ListObjectsV2 Prefix Filter | 3 calls | 0.58 s | 17,241 obj/s | $0.000015 |
| 20,000 objects | GetObjectTagging (32 workers) | 20,020 calls | 142.60 s | 140.2 obj/s | $0.00820 |
| 20,000 objects | ListObjectsV2 Prefix Filter | 5 calls | 1.48 s | 13,513 obj/s | $0.000025 |
At 20,000 objects, prefix filtering resolved in <b>1.48 seconds</b> using only 5 paginated API calls. In contrast, object tagging required <b>20,020 separate HTTP round-trips</b> and took over <b>2 minutes and 22 seconds</b> to finish, representing a 96x latency penalty and a 4,000x explosion in billable API requests.
Rate limits and 503 SlowDown hazards
Beyond raw latency, issuing tens of thousands of <code>GetObjectTagging</code> requests exposes systems to serious rate-limiting hazards. Standard AWS S3 partition limits cap GET requests at 5,500 requests per second per prefix. When scaling the worker pool to 64 concurrent threads to speed up tag retrieval, our client encountered intermittent <code>HTTP 503 SlowDown</code> errors, forcing backoff and retry logic that further inflated execution time.
Prefix hierarchies naturally avoid this bottleneck. When querying <code>ListObjectsV2</code> with a prefix, the storage cluster resolves the delimiter search in memory across indexed B-trees and returns 1,000 fully qualified matching keys in a single compressed response.
Python benchmark implementation
Here is the tested benchmark script used to demonstrate the <code>ListObjectsV2</code> prefix search efficiency:
When to use tags vs prefix hierarchies
Object tags are not useless, but they are designed for governance rather than application query filters:
- Use Object Tags for Lifecycle Management: S3 lifecycle rules natively support tag filters. For example, applying
ArchiveAfter=30dallows storage gateways to transition objects without renaming keys. - Use Object Tags for IAM Policies: Attribute-Based Access Control (ABAC) uses tags like
confidentiality=highto enforce dynamic read/write restrictions in IAM policy rules. - Use Object Tags for Cost Allocation: AWS Cost Explorer aggregates storage spend by tag across cost centers.
- Use Prefix Hierarchies for Application Queries: Whenever an application, worker daemon, or customer-facing API needs to search, list, or filter files, always encode the primary filter dimensions into the key prefix.
For complex search workloads requiring arbitrary multi-attribute filtering (e.g. searching across author, date ranges, and status simultaneously), pair prefix hierarchies with an external database catalog like PostgreSQL on tport.cloud or SQLite, keeping object storage strictly for raw byte persistence. See our guide on <a href="https://tport.space/articles/design-object-storage-keys-that-stay-searchable-at-10000-files">designing object-storage keys that stay searchable at scale</a>.