- Newest
- Most votes
- Most comments
Your thinking is largely on the right track. Here are the gaps and refinements worth considering. On the database layer: Database sharding via multiple RDS instances adds significant operational overhead for this use case. A more scalable and cost-effective approach is to keep a single Amazon Aurora PostgreSQL instance with read replicas for query scaling. Aurora auto-scales storage automatically and handles millions of rows well with proper indexing on your score column. If you genuinely need sharding at scale, Amazon Aurora Sharding via RDS Proxy is cleaner than managing shard nodes manually.
On scoring and ranking: Running the scoring model directly in Lambda works for lightweight models but will hit timeout and memory limits at millions of records. A better pattern is:
Run batch scoring on a schedule using AWS Batch or SageMaker Batch Transform Write scored results into a dedicated DynamoDB table or ElastiCache (Redis) keyed by customer ID with score as an attribute Front-end queries hit the cache not the database, giving you sub-millisecond reads at scale
On the API layer: Replace the SageMaker endpoint for front-end queries, ageMaker endpoints are for model inference, not data retrieval. Use API Gateway backed by Lambda to query your pre-scored results from DynamoDB or ElastiCache instead. On feedback and model retraining: Your CI/CD approach with CodePipeline and CodeBuild is correct. Add Amazon SageMaker Pipelines for the ML retraining loop specifically, it handles data versioning, model versioning, and automated retraining triggers more cleanly than CodeBuild alone.
Revised architecture summary: Aurora PostgreSQL → SageMaker Batch Transform (daily scoring) → DynamoDB or ElastiCache (scored results) → API Gateway + Lambda (front-end queries) → SageMaker Pipelines (feedback and retraining loop)
Reference: Amazon Aurora scaling: https://docs.aws.amazon.com/AmazonRDS/latest/AuroraUserGuide/Aurora.Managing.Performance.html
SageMaker Batch Transform: https://docs.aws.amazon.com/sagemaker/latest/dg/batch-transform.html
DynamoDB for high-performance reads: https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/best-practices.html
SageMaker Pipelines: https://docs.aws.amazon.com/sagemaker/latest/dg/pipelines.html
answered 5 months ago
Relevant content
- AWS OFFICIALUpdated 10 months ago
- AWS OFFICIALUpdated 2 years ago

Are you certain your data needs to be partitioned? Millions of records shouldn't be an issue for a database in general. Throughput sounds like your bigger concern, which can be managed via read replicas. A few other notes: APIG is not a load balancer, nor can it integrated directly with RDS for query ops. SageMaker is for inference, not for data query ops. I think you'd be better off using something like APIG->Lambda->RDS-RR. For ElastiCache, you'd need to think about what your cache key would be, which is hard to do with highly customizable query ranges. Food for thought.