# Strategy comparison

Ask a question about your documentation and see how each retrieval strategy responds side-by-side.

Try:
Showing precomputed sample output. Live queries use your configured API; no-key demo mode stays read-only.
Naive Vector

To connect Lambda to API Gateway and RDS, you need to: 1. Create a Lambda function with your application code 2. Create an API Gateway REST API and connect it to Lambda 3. Configure VPC settings on the Lambda function to access RDS 4. Set up the RDS database in a private subnet Make sure the Lambda function has the right IAM permissions and that the security groups allow traffic between Lambda and RDS.

420 ms 134 tok$0.00120

Sources

- lambda/latest/dg/configuration-vpc.html
- apigateway/latest/developerguide/getting-started.html

Contextual Vector

Setting up Lambda behind API Gateway with VPC access to RDS involves configuring several AWS services together. First, deploy your RDS instance in private subnets within a VPC. Then configure your Lambda function with VPC settings; attach it to the same VPC's private subnets and assign a security group. The Lambda security group must allow outbound traffic to the RDS security group on port 3306 (MySQL) or 5432 (PostgreSQL). For API Gateway, create a REST API with a Lambda proxy integration. The API Gateway invokes Lambda via the AWS service network, so it doesn't need VPC access itself. Key consideration: Lambda functions in a VPC need a NAT Gateway to access the internet (e.g., for calling other AWS APIs). Use VPC endpoints for services like S3 and DynamoDB to avoid NAT costs.

510 ms 167 tok$0.00180

Sources

- lambda/latest/dg/configuration-vpc.html
- AmazonRDS/latest/UserGuide/USER_VPC.html
- apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html

Knowledge Graph

This requires connecting 6 AWS resources in a specific dependency chain: API Gateway (REST API) → Lambda Function (proxy integration) Lambda Function → IAM Execution Role (AssumeRole: lambda.amazonaws.com) Lambda Function → VPC Configuration (SubnetIds + SecurityGroupIds) VPC → Private Subnets (where both Lambda ENIs and RDS reside) Security Group (Lambda) → Security Group (RDS) on port 5432 RDS Instance → Subnet Group (private subnets across 2+ AZs) The IAM execution role needs: AWSLambdaVPCAccessExecutionRole (for ENI creation in VPC), plus any RDS-specific permissions if using IAM database authentication. Critical constraint: Lambda in a VPC loses direct internet access. If your function needs to call external APIs or other AWS services, you need either a NAT Gateway ($0.045/hr + data) or VPC endpoints for specific services. Cold start impact: VPC-attached Lambda adds 1-10s cold start for ENI attachment. Use Provisioned Concurrency to mitigate this for latency-sensitive APIs.

890 ms 203 tok$0.00310

Sources

- lambda/latest/dg/configuration-vpc.html
- AmazonRDS/latest/UserGuide/USER_VPC.html
- apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
- lambda/latest/dg/lambda-intro-execution-role.html

Hybrid

This is a relational question requiring graph traversal (6 interconnected AWS resources). Routing to knowledge graph path. The dependency chain for API Gateway → Lambda → RDS: 1. API Gateway REST API with Lambda proxy integration handles HTTP routing and invokes Lambda 2. Lambda Execution Role (IAM) grants lambda.amazonaws.com AssumeRole + AWSLambdaVPCAccessExecutionRole managed policy 3. Lambda VPC Configuration attaches the function to private subnets via Elastic Network Interfaces (ENIs) 4. Security Group chain: Lambda SG allows outbound to RDS SG on port 5432/3306; RDS SG allows inbound from Lambda SG 5. RDS Subnet Group spans 2+ AZs in the same VPC private subnets 6. Optional: NAT Gateway or VPC Endpoints if Lambda needs internet or AWS API access Common pitfall: forgetting AWSLambdaVPCAccessExecutionRole on the execution role; Lambda silently fails to create ENIs and times out. Another: placing Lambda in public subnets thinking it will have internet access; it won't without a NAT Gateway. Cost implications: NAT Gateway adds ~$32/month base + $0.045/GB processed. For high-throughput APIs, consider VPC endpoints ($0.01/hr each) for frequently accessed AWS services like S3, DynamoDB, and Secrets Manager.

1050 ms 248 tok$0.00380

Sources

- lambda/latest/dg/configuration-vpc.html
- AmazonRDS/latest/UserGuide/USER_VPC.html
- apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html
- lambda/latest/dg/lambda-intro-execution-role.html
- vpc/latest/userguide/vpc-nat-gateway.html

QnA Pairs

To set up Lambda behind API Gateway with VPC access to RDS: 1. Deploy RDS in private subnets with a DB subnet group 2. Create a Lambda function and attach it to the same VPC private subnets 3. Configure security groups: Lambda SG → RDS SG on the database port 4. Attach AWSLambdaVPCAccessExecutionRole to the Lambda execution role 5. Create an API Gateway REST API with Lambda proxy integration Remember that VPC-attached Lambda needs a NAT Gateway for internet access and adds cold start latency.

680 ms 112 tok$0.00240

Sources

- lambda/latest/dg/configuration-vpc.html
- AmazonRDS/latest/UserGuide/USER_VPC.html

RAPTOR

Setting up Lambda behind API Gateway with VPC access to RDS requires coordinating several AWS services across networking, compute, and database layers. At the networking level, your VPC needs private subnets (for Lambda ENIs and RDS instances) across at least 2 AZs, security groups allowing Lambda-to-RDS traffic on the database port, and optionally a NAT Gateway if Lambda needs internet access for external API calls. For the compute layer, the Lambda function must be configured with VPC settings (SubnetIds and SecurityGroupIds) and an execution role that includes AWSLambdaVPCAccessExecutionRole for ENI management. Be aware that VPC-attached Lambda functions experience 1-10s cold starts due to ENI attachment. The API Gateway REST API connects to Lambda via proxy integration, routing HTTP requests to your function. API Gateway itself doesn't need VPC access; it invokes Lambda through the AWS service network. Key trade-off: VPC attachment adds cold start latency but is required for RDS access. Use Provisioned Concurrency for latency-sensitive APIs.

720 ms 189 tok$0.00280

Sources

- lambda/latest/dg/configuration-vpc.html
- AmazonRDS/latest/UserGuide/USER_VPC.html
- apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html

PageIndex

Based on the documentation structure, this question spans three main topic areas: Lambda VPC configuration, API Gateway integration, and RDS networking. Lambda VPC Configuration: Attach your Lambda function to private subnets in the same VPC as RDS. The function needs an execution role with AWSLambdaVPCAccessExecutionRole to create Elastic Network Interfaces (ENIs) in your subnets. Lambda functions in a VPC lose default internet access; add a NAT Gateway or VPC endpoints if needed. API Gateway Setup: Create a REST API with Lambda proxy integration. API Gateway invokes Lambda via the AWS internal network, so no VPC configuration is needed on the API Gateway side. The proxy integration passes the full HTTP request to your function. RDS Connectivity: Place RDS in a DB subnet group spanning private subnets across 2+ AZs. Configure security groups so the Lambda security group can reach the RDS security group on port 3306 (MySQL) or 5432 (PostgreSQL). Critical path: API Gateway → Lambda (proxy integration) → VPC ENI → Private Subnet → RDS. Cold starts add 1-10s for ENI attachment; use Provisioned Concurrency for production APIs.

950 ms 215 tok$0.00320

Sources

- lambda/latest/dg/configuration-vpc.html
- AmazonRDS/latest/UserGuide/USER_VPC.html
- apigateway/latest/developerguide/set-up-lambda-proxy-integrations.html