aws AWS Big Data Blog ·

AWS EMR and Spark: Reduce KMS Decrypt API Costs

blogdataawsengineerhealthcareaws-s3
announcement

This post details techniques for reducing AWS Key Management Service (KMS) decrypt API costs when processing encrypted Amazon S3 data with Apache Spark on Amazon EMR. Organizations processing large datasets can incur significant costs from frequent KMS decrypt calls, especially when per-object auditability is required, preventing the use of S3 Bucket Keys. The post introduces three optimization strategies: aggregating small files into larger ones, optimizing file formats with compression (e.g., Parquet, ORC, Iceberg), and leveraging AWS Glue Data Catalog partition indexes to minimize the number of AWS KMS API invocations.

  • Cost challenge with encrypted data in EMR Spark
  • Data aggregation to reduce redundant API calls
  • Optimizing file formats and compression
  • AWS Glue Data Catalog partition indexes
  • S3 Bucket Keys as a primary cost-saving measure
Enhancements (3)
  • Data aggregation to reduce redundant API calls

    Consolidating numerous small files into fewer, larger files reduces the total number of AWS KMS API invocations. This technique is effective for read-heavy workloads involving many small files stored on S3, directly lowering operational costs by minimizing decrypt operations per file.

  • Optimizing file formats and compression

    Selecting appropriate file formats like columnar Parquet/ORC and using compression (e.g., ZSTD, Snappy) minimizes the amount of data read from S3 and reduces the number of AWS KMS decrypt operations. Apache Iceberg is highlighted as a modern table format that simplifies data management and optimizes file layouts for large-scale analytic datasets.

  • AWS Glue Data Catalog partition indexes

    Utilizing AWS Glue Data Catalog partition indexes enables server-side filtering of partitions, reducing the number of S3 objects scanned and consequently decreasing AWS KMS API calls. This approach is beneficial for partitioned tables where AWS Glue returns only matching partitions, unlike the traditional method which scans all partitions and objects.

Notes (2)
  • Cost challenge with encrypted data in EMR Spark

    Organizations processing large amounts of encrypted Amazon S3 data on Amazon EMR with Apache Spark face rising costs due to frequent AWS KMS decrypt API calls. Each access to an encrypted S3 object triggers a decrypt call, which accumulates significantly at scale, particularly for workloads requiring per-object auditability that cannot use S3 Bucket Keys.

  • S3 Bucket Keys as a primary cost-saving measure

    While the post details techniques for further cost reduction, S3 Bucket Keys are identified as the most effective method to reduce AWS KMS decrypt API calls. The presented optimizations can be used alongside S3 Bucket Keys or independently when per-object auditability requirements prevent their use.

Read the original announcement →

https://aws.amazon.com/blogs/big-data/lowering-aws-kms-decrypt-api-costs-in-emr-spark-jobs/

Related releases