AWS Big Data Blog
Embracing event driven architecture to enhance resilience of data solutions built on Amazon SageMaker
Amazon Web Services (AWS) customers value business continuity while building modern data governance solutions. A resilient data solution helps maximize business continuity by minimizing solution downtime and making sure that critical information remains accessible to users. This post provides guidance on how you can use event driven architecture to enhance the resiliency of data solutions built on the next generation of Amazon SageMaker, a unified platform for data, analytics, and AI. SageMaker is a managed service with high availability and durability. If customers want to build a backup and recovery system on their end, we show you how to do this in this blog. It provides three design principles to improve the data solution resiliency of your organization. In addition, it contains guidance to formulate a robust disaster recovery strategy based on event driven architecture. It contains code samples to back up the system metadata of your data solution built on SageMaker, enabling disaster recovery.
The AWS Well-Architected Framework defines resilience as the ability of a system to recover from infrastructure or service disruptions. You can enhance the resiliency of your data solution by adopting three design principles that are highlighted in this post and by establishing a robust disaster recovery strategy. Recovery point objective (RPO) and recovery time objective (RTO) are industry standard metrics to measure the resilience of a system. RPO indicates how much data loss your organization can accept in case of solution failure. RTO refers to the time for the solution to recover after failure. You can measure these metrics in seconds, minutes, hours, or days. The next section discusses how you can align your data solution resiliency strategy to meet the needs of your organization.
Formulating a strategy to enhance data solution resilience
To develop a robust resiliency strategy for your data solution built on SageMaker, start with how users interact with the data solution. The user interaction influences the data solution architecture, the degree of automation, and determines your resiliency strategy. Here are a few aspects you might consider while designing the resiliency of your data solution.
- Data solution architecture – The data solution of your organization might follow a centralized, decentralized, or hybrid architecture. This architecture pattern reflects the distribution of responsibilities of the data solution based on the data strategy of your organization. This shift in responsibilities is reflected in the structure of the teams that perform activities in the Amazon DataZone data portal, SageMaker Unified Studio portal, AWS Management Console, and underlying infrastructure. Examples of such activities include configuring and running the data sources, publishing data assets in the data catalog, subscribing to data assets, and assigning members to projects.
- User persona – The user persona, their data, and cloud maturity influence their preferences for interacting with the data solution. The users of a data governance solution fall into two categories: business users and technical users. Business users of your organization might include data owners, data stewards, and data analysts. They might find the Amazon DataZone data portal and SageMaker Unified Studio portal more convenient for tasks such as approving or rejecting subscription requests and performing one-time queries. Technical users such as data solution administrators, data engineers, and data scientists might opt for automation when making system changes. Examples of such activities include publishing data assets, managing glossary and metadata forms in the Amazon DataZone data portal or in SageMaker Unified Studio portal. A robust resiliency strategy accounts for tasks performed by both user groups.
- Empowerment of self-service – The data strategy of your organization determines autonomy granted to the users. Increased user autonomy demands a high level of abstraction of the cloud infrastructure powering the data solution. SageMaker empowers self-service by enabling users to perform regular data management activities in the Amazon DataZone data portal and in the SageMaker Unified Studio portal. The level of self-service maturity of the data solution depends on the data strategy and user maturity of your organization. At an early stage, you might limit the self-service features to the use cases for onboarding the data solution. As the data solution scales, consider increasing the self-service capabilities. See Data Mesh Strategy Framework to learn about the different phases of a data mesh-based data solution.
Adopt the following design principles to enhance the resiliency of your data solution:
- Choose serverless services – Use serverless AWS services to build your data solution. Serverless services scale automatically with increasing system load, provide fault isolation, and have built-in high-availability. Serverless services minimize the need for infrastructure management, reducing the need to design resiliency into the infrastructure. SageMaker seamlessly integrates with several serverless services such Amazon Simple Storage Service (Amazon S3), AWS Glue, AWS Lake Formation, and Amazon Athena.
- Document system metadata – Document the system metadata of your data solution using infrastructure-as-code (IaC) and automation. Consider how users interact with the data solution. If the users prefer to perform certain activities through the Amazon DataZone data portal and SageMaker Unified Studio portal, implement automation to capture and store the metadata that’s relevant for disaster recovery. Use Amazon Relational Database Service (Amazon RDS) and Amazon DynamoDB to store the system metadata of your data solution.
- Monitor system health – Implement a monitoring and alerting solution for your data solution so that you can respond to service interruptions and initiate the recovery process. Make sure that system activities are logged so that you can troubleshoot the system interruption. Amazon CloudWatch helps you monitor AWS resources and the applications you run on AWS in real time.
The next section presents disaster recovery strategies to recover your data solution built on SageMaker.
Disaster recovery strategies
Disaster recovery focuses on one-time recovery objectives in response to natural disasters, large-scale technical failures, or human threats such as attack or error. Disaster recovery is a crucial part of your business continuity plan. As shown in the following figure, AWS offers the following options for disaster recovery: Backup and restore, pilot light, warm standby, and multi-site active/active.
The business continuity requirements and cost of recovery should guide your organization’s disaster recovery strategy. As a general guideline, the recovery cost of your data solution increases with reduced RPO and RTO requirements. The next section provides architecture patterns to implement a robust backup and recovery solution for a data solution built on SageMaker.
Solution overview
This section provides event-driven architecture patterns following the backup and restore approach to enhance resiliency of your data solution. This active/passive strategy-based solution stores the system metadata in a DynamoDB table. You can use the system metadata to restore your data solution. The following architecture patterns provide regional resilience. You can simplify the architecture of this solution to restore data in a single AWS Region.
Pattern 1: Point-in-time backup
The point-in-time backup captures and stores system metadata of a data solution built on SageMaker when a user or an automation performs an action. In this pattern, a user activity or an automation initiates an event that captures the system metadata. This pattern is suited for low RPO requirements, ranging from seconds to minutes. The following architecture diagram shows the solution for the point-in-time backup process.
The steps comprise the following.
- User or automation performs an activity on an Amazon DataZone domain or Amazon Unified Studio domain.
- This activity creates a new event in AWS CloudTrail.
- The CloudTrail event is sent to Amazon EventBridge. Alternatively, you can use Amazon DataZone as the event source for the EventBridge rule.
- AWS Lambda transforms and stores this event in a DynamoDB global table where the Amazon DataZone domain is hosted.
- The information is replicated into the replica DynamoDB table in a secondary Region. The replica DynamoDB table can be used to restore the data solution based on SageMaker in the secondary Region.
Pattern 2: Scheduled backup
The scheduled backup captures and stores system metadata of a data solution built on SageMaker at regular intervals. In this pattern, an event is initiated based on a defined time schedule. This pattern is suited for RPO requirements in the order of hours. The following architecture diagram displays the solution for point-in-time backup process.
The steps comprise the following.
- EventBridge triggers an event at regular interval and sends this event to AWS Step Functions.
- The Step Functions state machine contains multiple Lambda functions. These Lambda functions get the system metadata from either a SageMaker Unified Studio domain or an Amazon DataZone domain.
- The system metadata is stored in an DynamoDB global table in the primary Region where the Amazon DataZone domain is hosted.
- The information is replicated into the replica DynamoDB table in a secondary Region. The data solution can be restored in the secondary Region using the replica DynamoDB table.
The next section provides step by step instructions to deploy a code sample that implements the scheduled backup pattern. This code sample stores asset information of a data solution built on a SageMaker Unified Studio domain and an Amazon DataZone domain in an DynamoDB global table. The data in the DynamoDB table is encrypted at rest using a customer managed key stored in AWS Key Management Service (AWS KMS). A multi-Region replica key encrypts the data in the secondary Region. The asset uses the data lake blueprint that contains the definition for launching and configuring a set of services (AWS Glue, Lake Formation, and Athena) to publish and use data lake assets in the business data catalog. The code sample uses the AWS Cloud Development Kit (AWS CDK) to deploy the cloud infrastructure.
Prerequisites
- An active AWS account.
- AWS administrator credentials for the central governance account in your development environment
- AWS Command Line Interface (AWS CLI) installed to manage your AWS services from the command line (recommended)
- Node.js and Node Package Manager (npm) installed to manage AWS CDK applications
- AWS CDK Toolkit installed globally in your development environment by using npm, to synthesize and deploy AWS CDK applications
- TypeScript installed in your development environment or installed globally by using npm compiler:
- Docker installed in your development environment (recommended)
- An integrated development environment (IDE) or text editor with support for Python and TypeScript (recommended)
Walkthrough for data solutions built on a SageMaker Unified Studio domain
This section provides step by step instructions to deploy a code sample that implements the scheduled backup pattern for data solutions built on a SageMaker Unfied Studio domain.
Set up SageMaker Unified Studio
- Sign into the IAM console. Create an IAM role that trusts Lambda with the following policy.
- Note down the Amazon Resource Name (ARN) of the Lambda role. Navigate to SageMaker and choose Create a Unified Studio domain.
- Select Quick setup and expand the Quick setup settings section. Enter a domain name, for example,
CORP-DEV-SMUS
. Select the Virtual private cloud (VPC) and Subnets. Choose Continue. - Enter the email address of the SageMaker Unified Studio user in the Create IAM Identity Center user section. Choose Create domain.
- After the domain is created, choose Open unified studio in the top right corner.
- Sign in to SageMaker Unified Studio using the single sign-on (SSO) credentials of your user. Choose Create project at the top right corner. Enter a project name and description, choose Continue twice, and choose Create project. Wait unti project creation is complete.
- After the project is created, go into the project by selecting the project name. Select Query Editor from the Build drop-down menu on the top left. Paste the following create table as select (CTAS) query script in the query editor window and run it to create a new table named
mkt_sls_table
as described in Produce data for publishing. The script creates a table with sample marketing and sales data.
- Navigate to Data sources from the Project. Choose Run in the Actions section next to the project.default_lakehouse connection. Wait until the run is complete.
- Navigate to Assets in the left side bar. Select the
mkt_sls_table
in the Inventory section and review the metadata that was generated. Choose Accept All if you’re satisfied with the metadata. - Choose Publish Asset to publish the
mkt_sls_table
table to the business data catalog, making it discoverable and understandable across your organization. - Choose Members in the navigation pane. Choose Add members and select the IAM role you created in Step 1. Add the role as a Contributor in the project.
Deployment steps
After setting up SageMaker Unified Studio, use the AWS CDK stack provided on GitHub to deploy the solution to back up the asset metadata that is created in the previous section.
- Clone the repository from GitHub to your preferred integrated development environment (IDE) using the following commands.
- Export AWS credentials and the primary Region to your development environment for the IAM role with administrative permissions, use the following format
- Bootstrap the AWS account in the primary and secondary Regions by using AWS CDK and running the following command.
- Modify the following parameters in the
config/Config.ts
file.
- Install the dependencies by running the following command:
npm install
- Synthesize the CloudFormation template by running the following command.
cdk synth
- Deploy the solution by running the following command.
cdk deploy –all
- After the deployment is complete, sign in to your AWS account and navigate to the CloudFormation console to verify that the infrastructure deployed.
When deployment is complete, wait for the duration of DZ_BACKUP_INTERVAL_MINUTES
. Navigate to the <DZ_APPLICATION_NAME >AssetsInfo
DynamoDB table. Retrieve the data from the DynamoDB table. The following screenshot shows the data in the Items returned section. Verify the same data in the secondary Region.
Clean up
Use the following steps to clean up the resources deployed.
- Empty the S3 buckets that were created as part of this deployment.
- In your local development environment (Linux or macOS):
- Navigate to the
unified-studio
directory of your repository. - Export the AWS credentials for the IAM role that you used to create the AWS CDK stack.
- To destroy the cloud resources, run the following command:
cdk destroy --all
- Go to the SageMaker Unified Studio and delete the published data assets that were created in the project.
- Use the console to delete the SageMaker Unified Studio domain.
Walkthrough for data solutions built on an Amazon DataZone domain
This section provides step by step instructions to deploy a code sample that implements the scheduled backup pattern for data solutions built on an Amazon DataZone domain.
Deployment steps
After completing the prerequisites, use the AWS CDK stack provided on GitHub to deploy the solution to backup system metadata of the data solution built on Amazon DataZone domain
- Clone the repository from GitHub to your preferred IDE using the following commands.
- Export AWS credentials and the primary Region information to your development environment for the AWS Identity and Access Management (IAM) role with administrative permissions, use the following format:
- Bootstrap the AWS account in the primary and secondary Regions by using AWS CDK and running the following command:
- From the console for IAM, note the Amazon Resource Name (ARN) of the CDK execution role. Update the trust relationship of the IAM role so that Lambda can assume the role.
- Modify the following parameters in the
config/Config.ts
file.
- Install the dependencies by running the following command:
npm install
- Synthesize the AWS CloudFormation template by running the following command:
cdk synth
- Deploy the solution by running the following command:
cdk deploy --all
- After the deployment is complete, sign in to your AWS account and navigate to the CloudFormation console to verify that the infrastructure deployed.
Document system metadata
This section provides instructions to create an asset and demonstrates how you can retrive the metadata of the asset. Perform the following steps to retrieve the systems metadata.
- Sign in to the Amazon DataZone data portal from the console. Select the project and choose Query data at the upper right.
- Choose Open Athena and make sure that
<DZ_PROJECT_NAME>_DataLakeEnvironment
is selected in the Amazon DataZone environment dropdown at the upper right and that on the left, and that<DZ_PROJECT_NAME>_datalakeenvironment_pub_db
is selected as the Database. - Create a new AWS Glue table for publishing to Amazon DataZone. Paste the following create table as select (CTAS) query script in the Query window and run it to create a new table named
mkt_sls_table
as described in Produce data for publishing. The script creates a table with sample marketing and sales data.
- Go to the Tables and Views section and verify that the
mkt_sls_table
table was successfully created. - In the Amazon DataZone Data Portal, go to Data sources, select the
<DZ_PROJECT_NAME>-DataLakeEnvironment-default-datasource
, and choose Run. Themkt_sls_table
will be listed in the inventory and available to publish. - Select the
mkt_sls_table
table and review the metadata that was generated. Choose Accept All if you’re satisfied with the metadata. - Choose Publish Asset and the
mkt_sls_table
table will be published to the business data catalog, making it discoverable and understandable across your organization. - After the table is published, wait for the duration of
DZ_BACKUP_INTERVAL_MINUTES
. Navigate to the<DZ_APPLICATION_NAME >AssetsInfo
DynamoDB table and retrieve the data from the table. The following screenshot shows the data in the Items returned section. Verify the same data in the secondary Region.
Clean up
Use the following steps to clean up the resources deployed.
- Empty the Amazon Simple Storage Service (Amazon S3) buckets that were created as part of this deployment.
- Go to the Amazon DataZone domain portal and delete the published data assets that were created in the Amazon DataZone project.
- In your local development environment (Linux or macOS):
- Navigate to the
datazone
directory of your repository. - Export the AWS credentials for the IAM role that you used to create the AWS CDK stack.
- To destroy the cloud resources, run the following command:
cdk destroy --all
Conclusion
This post explores how to build a resilient data governance solution on Amazon SageMaker. Resilient design principles and a robust disaster recovery strategy are central to the business continuity of AWS customers. The code samples included in this post implement a backup process of the data solution at regular time interval. They store the Amazon SageMaker asset information in Amazon DynamoDB Global tables. You can extend the backup solution by identifying the system metadata that is relevant for the data solution of your organization and by using Amazon SageMaker APIs to capture and store the metadata. The DynamoDB Global table replicates the changes in the DynamoDB table in the primary region to the secondary region in an asynchronous manner. Consider Implementing an additional layer of resiliency by using AWS Backup to back up the DynamoDB table at regular interval. In the next post, we show how you can use the system metadata to restore your data solution in the secondary region.
Adopt the resiliency features offered by Amazon DataZone and Amazon SageMaker Unified Studio. Use AWS Resilience Hub to assess the resilience of your data solution. AWS Resilience Hub helps you to define your resilience goals, assess your resilience posture against those goals, and implement recommendations for improvement based on the AWS Well-Architected Framework.
To build a data mesh based data solution using Amazon DataZone domain, see our GitHub repository. This open source project provides a step-by-step blueprint for constructing a data mesh architecture using the powerful capabilities of Amazon SageMaker, AWS Cloud Development Kit (AWS CDK), and AWS CloudFormation.
About the authors
Dhrubajyoti Mukherjee is a Cloud Infrastructure Architect with a strong focus on data strategy, data governance, and artificial intelligence at Amazon Web Services (AWS). He uses his deep expertise to provide guidance to global enterprise customers across industries, helping them build scalable and secure cloud solutions that drive meaningful business outcomes. Dhrubajyoti is passionate about creating innovative, customer-centric solutions that enable digital transformation, business agility, and performance improvement. Outside of work, Dhrubajyoti enjoys spending quality time with his family and exploring nature through his love of hiking mountains.