AWS Builder Center

Set Up Amazon S3 Tables and Amazon Athena for Higher Transaction Throughput and Automatic Small-File Compaction Through the AWS Console - Part 2

Set Up Amazon S3 Tables and Amazon Athena for Higher Transaction Throughput and Automatic Small-File Compaction Through the AWS Console - Part 2

Series: Financial Service (33 articles)

  1. …
  2. 31
    Set Up Amazon S3 Tables and Amazon Athena for Higher Transaction Throughput and Automatic Small-File Compaction Through the AWS Console - Part 2 This article
Dev @ Vertex Macro

Step 13: Review Default S3 Tables Maintenance

Open the Amazon S3 console. Choose Table buckets. Open the pilot table bucket, the  executions  namespace, and  normalized_execution_events .
Open the Maintenance, Optimization, or Table maintenance tab shown by the current console.
Review compaction, snapshot management, and unreferenced-file removal. S3 Tables enables managed maintenance capabilities to continuously optimize table performance and storage cost.
Open the compaction configuration. Review whether it is enabled. Review the strategy, target file size, thresholds, and status fields exposed by the console.
Do not disable compaction simply because the pilot data volume is small. A pilot should demonstrate how managed maintenance behaves before production scale.
Open snapshot-management settings. Review the retention period and minimum snapshots. Align the values with rollback, time-travel, long-running-reader, and incident-investigation requirements.
Open unreferenced-file-removal settings. Review the retention interval. Keep a safety interval longer than the longest credible writer duration, retry interval, and investigation period.
Do not create generic S3 lifecycle rules against internal S3 Tables data objects. Table maintenance must follow Iceberg snapshot reachability.

Step 14: Configure Small-File Compaction

In the table Maintenance area, choose Edit compaction configuration when the console exposes the control.
Enable compaction.
Select the default bin-pack strategy for the first implementation. Bin packing consolidates small files into fewer larger files and is the safest general starting point.
Set the target file size using observed query and ingestion behavior. A range from 128 MiB to 512 MiB is a reasonable analytical starting point, but it is not a universal requirement. Smaller files may improve parallelism and reduce rewrite scope. Larger files reduce file-open and planning overhead.
Review the minimum input-file count or threshold settings shown by the console. Avoid a threshold so low that the service repeatedly rewrites nearly healthy files. Avoid a threshold so high that thousands of small files accumulate before maintenance begins.
If the console exposes sort compaction, use it only after defining a table sort order aligned with important predicates. For an execution table, a sort order based on business date and instrument, account, venue, or event timestamp may improve file pruning depending on the query portfolio.
If z-order compaction is available, use it only when queries repeatedly filter across several dimensions and a single hierarchical sort cannot serve them well. Measure the result rather than assuming that a more advanced strategy is automatically better.
Choose Save changes.
Return to the maintenance page. Confirm that compaction is enabled and that the configuration status is active.

Step 15: Create a Controlled Small-File Workload

Use a non-production table. Do not intentionally create small files in a production analytical table merely to demonstrate maintenance.
In AWS Glue or EMR, configure a test writer that sends many small micro-batches. Each batch should contain a deterministic batch identifier and synthetic execution rows.
Write enough batches to create a visible small-file condition. Keep the workload within account quotas and cost controls.
Open the Amazon S3 console and return to the S3 table. Review the table’s maintenance and storage statistics. Record the initial file count, average file size, snapshot count, and compaction status if these values are exposed.
Open Athena and query Iceberg metadata tables supported by the current integration. Use the table’s files metadata to inspect file size and partition distribution. The exact Athena metadata-table syntax depends on the catalog integration and engine support.
A representative query pattern is shown below. Adjust the catalog and table naming syntax to the current Athena integration.
SELECT
file_path,
file_size_in_bytes,
record_count,
partition
FROM "normalized_execution_events$files"
ORDER BY file_size_in_bytes ASC;
Run the query. Record the number of small files and their size distribution.
Wait for the managed compaction process to run according to the service schedule and configuration. S3 Tables performs maintenance asynchronously. Do not treat the lack of an immediate rewrite as a failure.
Return to the S3 Tables maintenance page. Review maintenance job status, last run, files processed, bytes processed, or other execution details exposed by the console.
Run the metadata query again. Confirm that the number of small files decreases and the resulting files move toward the configured target size.

Step 16: Measure Athena Query Improvement After Compaction

In Athena, select the same workgroup, catalog, and database used before compaction.
Run a representative query before compaction and preserve the query execution ID, execution time, data scanned, and result count.
SELECT
instrument_id,
venue,
SUM(quantity) AS executed_quantity,
SUM(quantity * price) AS executed_notional
FROM normalized_execution_events
WHERE business_date = DATE '2026-10-30'
GROUP BY instrument_id, venue;
After compaction completes, run the exact same query against an equivalent committed state or account for any newly ingested rows. Record the query execution ID, execution time, data scanned, and file distribution.
Open Recent queries and choose each execution. Review Query statistics. Compare planning time, execution time, and scanned data.
Compaction primarily reduces file and planning overhead. It does not guarantee that every query scans fewer logical bytes. Sort or z-order layout can improve pruning when filters align with the physical organization.
If query time does not improve, inspect whether the workload was already large-file efficient, whether the predicate is nonselective, whether file statistics overlap broadly, or whether the test is dominated by result production rather than file opens.

Step 17: Configure Monitoring and Operational Evidence

Open the Amazon CloudWatch console. Choose Log groups. Locate log groups for AWS Glue, EMR, Athena, CloudTrail, and relevant S3 Tables activity exposed through the selected monitoring path.
Create metric filters or alarms for failed ingestion jobs, repeated Iceberg commit conflicts, S3 503 Slow Down responses, compaction failures, snapshot-management failures, and unreferenced-file-removal failures where the service publishes the required signals.
In Athena, enable workgroup CloudWatch metrics. Monitor processed bytes, successful queries, failed queries, and execution time.
In the AWS Glue or EMR job, publish application metrics for batch ID, base snapshot ID, committed snapshot ID, rows written, files written, commit duration, retry count, and reconciliation status.
Open AWS CloudTrail. Choose Event history. Filter for the S3 Tables, Glue, Athena, IAM, Lake Formation, and KMS events relevant to the setup. Confirm that administrative and data-control actions are logged.
Send durable logs to a central security or audit account according to the enterprise architecture. Workload administrators should not control the only evidence of their own changes.
Tag the table bucket, roles, workgroup, query-results bucket, and Glue jobs with business owner, technical owner, environment, cost center, data classification, and service name.

Step 18: Migrate a Self-Managed Trading-Desk Iceberg Table

Inventory the existing table. Record catalog type, object location, Iceberg format version, schemas, partition specifications, sort orders, snapshots, delete files, commit frequency, file sizes, maintenance jobs, readers, writers, encryption, permissions, and business owner.
Identify consumers that read Parquet directly or list S3 prefixes. They bypass Iceberg snapshot and delete semantics and must be migrated to a catalog-aware access path.
Create the target namespace and S3 Table using the approved schema and partition design.
Use AWS Glue or EMR to read one committed source snapshot and write to the target S3 Table through the supported Iceberg catalog. Preserve the source snapshot ID, data cutoff, row counts, hashes where practical, economic totals, and transformation version.
Run source and target in parallel. Reconcile source sequences, business keys, quantities, prices, notionals, corrections, and duplicates for every batch.
Compare commit throughput, file creation, maintenance effort, query planning, bytes scanned, and monthly cost. Use identical workload conditions.
Cut over readers only after the target produces reproducible business results. Keep the former table read-only during the defined rollback period.
Retire the self-managed maintenance jobs only after confirming that S3 Tables performs compaction, snapshot management, and unreferenced-file cleanup according to the required policy.

Step 19: Establish the Trading-Desk Operating Discipline

Technical consistency must be matched by human candor.
Google’s psychological-safety principle should be implemented as an operational mechanism. Engineers, analysts, operations staff, and control functions must be able to report missing exchange sequences, weakened query performance, commit conflicts, unexpected compaction, and reconciliation differences without fear of humiliation.
Amazon’s Leadership Principles provide execution discipline. Customer Obsession includes the trader, risk manager, client, operations team, auditor, and regulator relying on the result. Ownership means following a failed batch through business reconciliation. Dive Deep means inspecting snapshots, files, commit latency, and query statistics rather than accepting a green job. Insist on the Highest Standards means that an unexplained difference remains open. Have Backbone; Disagree and Commit protects evidence-based challenge and coordinated execution. Earn Trust requires precise statements about TPS and compaction rather than overstated benchmark claims.
Bridgewater Associates’ emphasis on extreme truth and transparency and idea meritocracy should direct design reviews toward evidence. A position should be accepted because workload measurements, query evidence, snapshot history, and reconciliation support it, not because the presenter is senior. Transparency remains bounded by privacy, confidentiality, market-conduct, and need-to-know obligations.
Alfred Adler’s emphasis on belonging and contribution helps the platform team understand the purpose of maintenance work. Compaction is not merely file housekeeping. It protects the desk from unpredictable analysis latency and returns engineering capacity to higher-value controls.
Nonviolent communication improves incident handling. State the observation, operational effect, need, and requested action. A precise statement that file count increased fivefold and Athena planning time doubled is more actionable than accusing the ingestion team of poor engineering.
Tactical empathy helps when a trading desk fears losing control to a managed service. Acknowledge the requirement to inspect committed snapshots, reproduce reports, understand maintenance effects, and recover during market stress. Build confidence through evidence and rehearsed operations rather than relying on the phrase fully managed.

Step 20: Manage Cost and Continue Optimization

Open AWS Cost Explorer. Filter by the S3, S3 Tables, Athena, Glue, EMR, KMS, and data-transfer services used by the implementation.
Create cost-allocation tags and activate them in Billing. Allocate cost to the trading-data product rather than leaving it in a general cloud account.
Monitor S3 Tables storage, maintenance, requests, and related catalog charges. Monitor Athena bytes scanned. Monitor Glue DPU-hours or EMR compute. Monitor KMS request volume and data transfer.
Compare cost per million ingested rows, cost per committed batch, cost per representative query, and monthly maintenance effort with the self-managed baseline.
Tune batch size before trying to solve every small-file problem through compaction. Compaction is a managed optimization, not permission to create pathological writer output.
Tune partitioning and sort order from real predicates. Avoid high-cardinality partitioning. Use sort or z-order strategies only after proving they improve important queries.
Review transaction throughput during market peaks and corrections. More commits are not automatically better. The best commit frequency balances freshness, file size, retry scope, and downstream query health.
Review the compatibility of every engine before adopting Iceberg V3 features or new row-level delete representations. One unsupported reader can turn a technically valid table into an operational control failure.
The durable objective is not maximum TPS or the largest possible compacted file. The durable objective is a governed trading-data system that commits changes predictably, serves queries efficiently, preserves evidence, and reduces the operational work required to keep Apache Iceberg healthy.

References

Amazon Web Services Documentation, “Working with Amazon S3 Tables and table buckets.”  https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables.html 
Amazon Web Services Documentation, “Tutorial: Getting started with S3 Tables.”  https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-getting-started.html 
Amazon Web Services Documentation, “S3 Tables maintenance.”  https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-maintenance-overview.html 
Amazon Web Services Documentation, “Maintenance for tables.”  https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-maintenance.html 
Amazon Web Services Documentation, “Querying Amazon S3 tables with Athena.”  https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-integrating-athena.html 
Amazon Web Services Documentation, “Register S3 table bucket catalogs and query tables from Athena.”  https://docs.aws.amazon.com/athena/latest/ug/gdc-register-s3-table-bucket-cat.html 
Amazon Web Services Documentation, “Accessing table data.”  https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-access.html 
Amazon Web Services Documentation, “Integrating Amazon S3 Tables with AWS analytics services.”  https://docs.aws.amazon.com/AmazonS3/latest/userguide/s3-tables-integrating-aws.html 
Amazon Web Services Documentation, “Integrating with Amazon S3 Tables in AWS Glue.”  https://docs.aws.amazon.com/glue/latest/dg/glue-federation-s3tables.html 
Amazon Web Services Documentation, “AWS Lake Formation permissions reference.”  https://docs.aws.amazon.com/lake-formation/latest/dg/lf-permissions-reference.html 
Apache Iceberg Documentation, “Maintenance.”  https://iceberg.apache.org/docs/latest/maintenance/ 
Apache Iceberg Documentation, “Configuration.”  https://iceberg.apache.org/docs/latest/configuration/ 

Series: Financial Service (33 articles)

  1. …
  2. 31
    Set Up Amazon S3 Tables and Amazon Athena for Higher Transaction Throughput and Automatic Small-File Compaction Through the AWS Console - Part 2 This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article