AWS Glue Data Catalog supports automatic optimization of Apache Iceberg tables through your Amazon VPC
The AWS Glue Data Catalog supports automatic table optimization of Apache Iceberg tables, including compaction, snapshots, and orphan data management. The data compaction optimizer constantly monitors table partitions and kicks off the compaction process when the threshold is exceeded for the number of files and file sizes.
The Iceberg table compaction process starts and will continue if the table or any of the partitions within the table has more than the configured number of files (default five files), each smaller than 75% of the target file size. The snapshot retention process runs periodically (default daily) to identify and remove snapshots that are older than the specified retention configuration from the table properties, while keeping the most recent snapshots up to the configured limit. Similarly, the orphan file deletion process scans the table metadata and the actual data files, identifies the unreferenced files, and deletes them to reclaim storage space. These storage optimizations can help you reduce metadata overhead, control storage costs, and improve query performance.
Although automatic table optimization has simplified day-to-day Iceberg table maintenance tasks, certain industries and customers have advanced requirements to access their Iceberg tables from specific virtual private clouds (VPCs). This access control is needed for not only data ingestion and querying, but also for table maintenance.
To help achieve such requirements, we provide the capability where the Data Catalog optimizes Iceberg tables to run in your specific VPC. This post demonstrates how it works with step-by-step instructions.
How the table optimizer works with AWS Glue network connection
By default, a table optimizer is not associated with any of your VPCs and subnets. With this new capability of supporting data access from VPCs, you can associate a table optimizer with an AWS Glue network connection to run in a specific VPC, subnet, and security group. An AWS Glue network connection is commonly used to run an AWS Glue job with a specific VPC, subnet, and security group. The following diagram illustrates how it works.
In the next sections, we demonstrate how to configure a table optimizer with an AWS Glue network connection.
Prerequisites
To run through this instruction, you must have the following prerequisites:
Set up resources with AWS CloudFormation
This post includes a sample AWS CloudFormation template that enables a quick setup of the solution resources. You can review and customize the template to suit your needs.
The CloudFormation template generates the following resources:
- An Amazon Simple Storage Service (Amazon S3) bucket to store the dataset, AWS Glue job scripts, and so on. (See Appendix 1 at the end of this post for manual instructions.)
- A Data Catalog database.
- An AWS Glue job that creates and modifies sample customer data in your S3 bucket with a trigger every 10 minutes.
- AWS IAM roles and policies.
- A VPC, public subnet, two private subnets, internet gateway, and route tables.
- Amazon Virtual Private Cloud (Amazon VPC) endpoints for AWS Glue, AWS Lake Formation, Amazon CloudWatch, Amazon S3, and AWS Security Token Service (AWS STS). The endpoint names are as follows:
- AWS Glue –
com.amazonaws.<region>.glue
(for example,com.amazonaws.us-east-1.glue
). - Lake Formation –
com.amazonaws.<region>.lakeformation
(only if tables are registered with Lake Formation). - CloudWatch –
com.amazonaws.<region>.monitoring
. - Amazon S3 –
com.amazonaws.<region>.s3
. - AWS STS –
com.amazonaws.<region>.sts
.
- AWS Glue –
- An AWS Glue network connection configured with the VPC and subnet. (See Appendix 2 at the end of this post for manual instructions.)
To launch the CloudFormation stack, complete the following steps:
- Sign in to the AWS CloudFormation console.
- Choose Launch Stack.
- Choose Next.
- For SubnetAz1, choose your preferred Availability Zone.
- For SubnetAz2, choose your preferred Availability Zone. This needs to be different from
SubnetAz1
. - Leave the other parameters as default or make appropriate changes based on your requirements, then choose Next.
- Review the details on the final page and select I acknowledge that AWS CloudFormation might create IAM resources.
- Choose Create.
This stack can take around 5–10 minutes to complete, after which you can view the deployed stack on the AWS CloudFormation console.
Configure automatic table optimization with an AWS Glue network connection
Complete following steps to configure automatic table optimization with an AWS Glue network connection:
- On the AWS Glue console, choose Databases in the navigation pane.
- Choose
iceberg_optimizer_vpc_db
. - Under Tables, choose
customer
. - On the Table optimization – new tab, choose Enable optimization.
- For Optimization configuration, choose Customize settings.
- For IAM role, choose the
iceberg-optimizer-vpc-MyGlueTableOptimizerRole-xxx
role created by the CloudFormation stack. - For Virtual private cloud (VPC) – optional, choose
myvpc_private_network_connection
.
- Select I acknowledge that expired data will be deleted as part of the optimizers and choose Enable optimization.
Now the table optimizer has been configured with your VPC. After a while, you can see how the optimizer worked.
- Under Table optimization – new, choose View optimization history on the Actions menu.
You can confirm that the table optimizer worked successfully for this Iceberg table.
You have now seen how to set up the table optimizer with an AWS Glue network connection to run it through a specific VPC.
Clean up
When you have finished all the preceding steps, remember to clean up all the AWS resources you created using AWS CloudFormation:
- Delete the S3 bucket storing the Iceberg table and the AWS Glue job script.
- Delete the CloudFormation stack.
Conclusion
This post demonstrated how the Data Catalog supports automatic optimization of Iceberg tables through your VPC. With this enhancement, you can simplify table maintenance for your Iceberg tables under advanced security requirements. This feature is available today in all AWS Glue supported AWS Regions.
Try out this solution for your own use case, and share your feedback and questions in the comments.
About the Authors
Noritaka Sekiyama is a Principal Big Data Architect on the AWS Glue team. He is responsible for building software artifacts to help customers. In his spare time, he enjoys cycling with his new road bike.
Paul Villena is an Analytics Solutions Architect in AWS with expertise in building modern data and analytics solutions to drive business value. He works with customers to help them harness the power of the cloud. His areas of interest are infrastructure as code, serverless technologies, and coding in Python.
Justin Lin is a software engineer on the AWS Lake Formation team. He works on delivering managed optimization solutions for open table formats to enhance customer data management and query performance. In his spare time, he enjoys playing tennis.
Himani Desai is a Software Engineer on the AWS Lake Formation team. She works on providing managed optimization solutions for Iceberg tables.
Abishek Shankar is a software engineer on the AWS Lake Formation team, working on providing managed optimization solutions for Iceberg tables.
Shyam Rathi is a Software Development Manager on the AWS Lake Formation team, working on delivering new features and enhancements related to modern data lakes.
Sandeep Adwankar is a Senior Product Manager at AWS. Based in the California Bay Area, he works with customers around the globe to translate business and technical requirements into products that enable customers to improve how they manage, secure, and access data.
Appendix 1: Configure your S3 bucket to allow access only from a specific VPC
The instructions provided in this post help you configure your S3 bucket automatically through the CloudFormation template, but you can also manually configure your S3 bucket to allow access only from a specific VPC. This is an optional step to simulate the strict security regulation on your Iceberg table. Complete following steps:
- On the Amazon S3 console, choose Buckets in the navigation pane.
- Choose your S3 bucket.
- Choose Permissions.
- Under Bucket policy, choose Edit.
- Enter following bucket policy:
- Choose Save changes.
Now this S3 bucket prevents any data operations not from the VPC. You can try uploading files to the bucket through Amazon S3 console to see that this operation fails as expected.
Appendix 2: Create an AWS Glue network connection
You can also can manually configure the AWS Glue network connection with the following steps:
- On the AWS Glue console, choose Data connections in the navigation pane.
- Under Connections, choose Create connection.
- Select Network, and choose Next.
- For VPC, choose your VPC created by the CloudFormation stack. The VPC ID is shown on the Outputs tab of the CloudFormation stack.
- For Subnet, choose your private subnet created by the CloudFormation stack. The subnet ID is shown on the Outputs tab of the CloudFormation stack.
- For Security groups, choose your security group created by the CloudFormation stack. The security group ID is shown on the Outputs tab of the CloudFormation stack.
- Choose Next.
- For Name, enter
myvpc_private_network_connection
. - Choose Next.
- Review the configurations and choose Create connection.
Post Comment