Building async Python applications with Tortoise ORM and Amazon Aurora DSQL
Database Blog
This article demonstrates building high-concurrency async Python applications using Tortoise ORM paired with Amazon Aurora DSQL, using a rideshare platform as an example.
- Tortoise ORM is an async-native Python ORM with Django-like syntax that integrates seamlessly with Aurora DSQL's serverless architecture
- Use UUID primary keys for distributed-friendly key generation and manage relationships as UUID columns to minimize optimistic concurrency control conflicts
- Authenticate with short-lived IAM tokens via Boto3's DSQL client instead of static passwords; patch asyncpg's connection reset to skip unsupported advisory lock calls
- Implement OCC retry logic with exponential backoff and jitter to handle serialization errors when concurrent transactions modify the same row
- Execute each DDL statement individually through raw asyncpg connections since Aurora DSQL doesn't support multiple DDL statements per transaction
- Deploy with TLS encryption, least-privilege IAM roles, VPC isolation, and connection pool tuning for production workloads
The combination of Tortoise ORM's native async coroutines and Aurora DSQL's serverless scalability provides a strong foundation for high-concurrency Python applications like rideshare platforms, delivery tracking, and real-time marketplaces.
The AWS News Feed is currently looking for gold sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.
Related articles
The AWS News Feed is currently looking for silver sponsors. If you want to support the AWS community and reach a large audience of AWS professionals, consider sponsoring the AWS News Feed.