Performance benchmark diagram comparing S3 GetObjectTagging versus ListObjectsV2 prefix hierarchies across 20,000 objects

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 tags dept=finance and status=archived applied 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 sizeQuery approachAPI requests madeTotal wall timeThroughput (objs/sec)API cost per query
1,000 objectsGetObjectTagging (32 workers)1,001 calls7.42 s134.7 obj/s$0.00041
1,000 objectsListObjectsV2 Prefix Filter1 call0.12 s8,333 obj/s$0.000005
5,000 objectsGetObjectTagging (32 workers)5,005 calls36.18 s138.2 obj/s$0.00205
5,000 objectsListObjectsV2 Prefix Filter2 calls0.31 s16,129 obj/s$0.000010
10,000 objectsGetObjectTagging (32 workers)10,010 calls71.50 s139.8 obj/s$0.00410
10,000 objectsListObjectsV2 Prefix Filter3 calls0.58 s17,241 obj/s$0.000015
20,000 objectsGetObjectTagging (32 workers)20,020 calls142.60 s140.2 obj/s$0.00820
20,000 objectsListObjectsV2 Prefix Filter5 calls1.48 s13,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:

python
import time
import boto3

s3 = boto3.client('s3', endpoint_url='https://s3.tport.space')

def query_by_prefix(bucket: str, prefix: str) -> list:
    start = time.perf_counter()
    paginator = s3.get_paginator('list_objects_v2')
    matching_keys = []
    request_count = 0
    
    for page in paginator.paginate(Bucket=bucket, Prefix=prefix):
        request_count += 1
        for obj in page.get('Contents', []):
            matching_keys.append(obj['Key'])
            
    elapsed = time.perf_counter() - start
    print(f"Prefix query matched {len(matching_keys)} objects in {elapsed:.2f}s ({request_count} API calls)")
    return matching_keys

# Query 4,200 matching keys across 20,000 items in 1.48s
query_by_prefix('enterprise-docs', 'dept=finance/status=archived/')

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=30d allows storage gateways to transition objects without renaming keys.
  • Use Object Tags for IAM Policies: Attribute-Based Access Control (ABAC) uses tags like confidentiality=high to 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>.