- Newest
- Most votes
- Most comments
After testing different approaches, here's what worked best for my tarot card API:
1. HTTP API vs REST API I went with HTTP API (v2) — it's ~70% cheaper and has lower latency for simple JSON APIs. REST API is better if you need request validation, API keys, or usage plans.
2. Lambda Configuration For a simple Python function returning JSON from an in-memory dataset (78 tarot cards), 128MB memory and 10s timeout is more than enough. Average response time is under 50ms.
3. Cold Start Optimization
- Keep the function small (single file, no heavy dependencies)
- Use Python 3.12 runtime (faster cold starts than 3.9)
- The dataset is embedded in the code, so no external DB calls needed
Deployment Options I've set up:
- SAR (one-click deploy): Search "tarot-card-meanings-api" in the Serverless Application Repository
- CDK construct:
npm install cdk-tarot-reading-api— deploys Lambda + API Gateway in 3 lines of code - Docker: Available on ECR Public Gallery
Resources:
- Source code: https://github.com/gokimedia/tarot-reading
- NPM package (card data only): https://www.npmjs.com/package/tarot-card-meanings
- PyPI package: https://pypi.org/project/tarot-card-meanings/
- Live implementation: https://deckaura.com/pages/free-tarot-reading
- CDK construct: https://www.npmjs.com/package/cdk-tarot-reading-api
repost.aws adresine gidip yapıştırın. Hem soru hem cevap sizin hesabınızdan olabilir — "self-answered question" re:Post'ta normal.
Based on AWS best practices for serverless APIs, here are recommendations for your tarot card reading API:
1. REST API vs HTTP API: For your use case, an HTTP API is recommended. HTTP APIs offer minimal features at a lower cost compared to REST APIs, making them ideal for straightforward serverless applications. Since you're focused on keeping costs low and your API serves JSON responses without complex authorization requirements, HTTP API would be the better choice.
2. Memory and Timeout Configuration: For a Lambda function that returns simple JSON responses (like tarot card meanings), you can start with minimal settings:
- Memory: 128-256 MB should be sufficient for basic JSON operations
- Timeout: 3-10 seconds is typically adequate for simple data retrieval and response formatting
Since Lambda pricing is based on execution time and memory allocation, starting with lower values and monitoring performance will help optimize costs while staying within the free tier.
3. Minimizing Cold Starts: To reduce cold start impact:
- Optimize function performance by keeping your deployment package small and minimizing dependencies
- Handle cold starts gracefully in your code design
- Manage dependencies efficiently - only include what's necessary for your tarot card data and logic
- Consider the trade-off between memory allocation and execution speed, as higher memory can sometimes reduce cold start duration
For monitoring and debugging, use AWS CloudWatch to gain insights into your function's execution patterns and identify any performance bottlenecks. This will help you fine-tune your configuration based on actual usage patterns.
Since your API primarily serves static tarot card data with interpretations, the serverless architecture with Lambda and API Gateway is well-suited for handling variable request loads while keeping costs minimal.
Sources
Get started with API Gateway - Amazon API Gateway
Community | Demystifying AWS Lambda: Deep Dive into Serverless Computing
