1 Answer
- Newest
- Most votes
- Most comments
0
Advantages of using API Gateway
- Authentication and Authorization: Integrates well with IAM, Cognito, or custom authorizers to secure access.
- Rate Limiting and Throttling: Protects expensive Bedrock interactions from abuse or accidental overuse.
- Custom Domains: Adds a layer of flexibility for exposing the endpoint publicly.
- Built-in caching to reduce Bedrock calls
- Timeout Increase (Post-April 2024): Default is 29 seconds; but for Regional REST APIs and private REST APIs it can increase beyond 29 seconds, but this might require a reduction in your account-level throttle quota limit.
Advantages of using Lambda
- Add custom logic or preprocessing before sending requests to Bedrock
- Security Boundary: Keeps Bedrock credentials hidden from clients and encapsulates business logic.
- Retries & Error Handling: Can handle transient errors or implement fallbacks/retry logic for Bedrock
Disadvantages of the Topology
- Additional latency due to multiple hops
- No Streaming Support in REST/HTTP API Gateway
- Higher cost per request (API GW + Lambda + Bedrock)
- For infrequent calls, Lambda cold starts may introduce initial latency. Provisioned concurrency can help, but it's an added cost.
- Payload Size Limits: Lambda has limits (~6 MB for sync invocation), so watch out for large prompt/response interactions.
Best Practices around this architecture
- Use provisioned concurrency for Lambda to minimize cold starts
- Consider using WebSocket API if streaming is required
- Use AWS X-Ray for distributed tracing
- Consider implementing a dead-letter queue for failed requests
Relevant content
- asked 6 months ago
- asked 3 years ago