Your application running on EC2 suddenly starts failing health checks behind an ALB. How would you troubleshoot the issue step by step?
Show the answer
Check ALB target group: AWS Console → EC2 → Target Groups → select the TG → Targets tab. Look at the health status reason for each instance (e.g., "Request timed out", "Connection refused", "HTTP 5xx").
Check ALB access logs: enable and review logs in S3 for target_status_code and target_processing_time on the failing target.
CloudWatch metrics: check UnHealthyHostCount, TargetResponseTime, and HTTPCode_Target_5XX_Count.
SSH to the EC2 instance: test the health check endpoint locally:
curl -v http://localhost:<port>/health
If it succeeds locally but fails from ALB, the issue is network-level (security group, NACL). If it fails locally, the application is down.
Application logs: journalctl -u myapp -n 200 or check /var/log/app/. Look for OOM, startup errors, DB connection failures.
Security groups: verify the ALB security group is allowed as an inbound source in the EC2 security group on the health check port.
Resource exhaustion: top, df -h, free -m — check CPU, disk, and memory. A full disk or OOM can cause the app to crash.
Recent changes: check deploy history, AMI change, user-data script changes, or security group rule modifications.
If an S3 bucket accidentally gets deleted, how would you recover the data?
Show the answer
Versioning enabled: S3 versioning adds a delete marker on deletion. Recover by removing the delete marker:
Or restore all objects by removing all delete markers with a script.
S3 Replication: if cross-region or same-region replication is configured, the data exists in the destination bucket.
AWS Backup: if the bucket was backed up via AWS Backup, restore from the recovery point.
Versioning + MFA Delete: the strongest protection — deletion of versioned objects requires MFA. If MFA Delete was enabled, the bucket can't have been deleted without MFA.
If no protection was in place: file an AWS Support ticket immediately (Premium Support can sometimes recover recently deleted S3 data within hours). No guarantees.
Prevention: enable versioning + MFA Delete, use an S3 bucket policy denying s3:DeleteBucket and s3:DeleteObject except for specific roles, enable Object Lock (WORM) for critical data.
Your Lambda function is timing out frequently. How do you troubleshoot and optimize it?
Show the answer
Troubleshoot:
CloudWatch Logs: look for "Task timed out after X seconds" — check what the function was doing at that point.
X-Ray tracing: enable active tracing (aws lambda update-function-configuration --tracing-config Mode=Active); view the trace to see which segment (DB call, external API, S3) is slow.
Database connection: Lambda creates a new DB connection on cold start. Use RDS Proxy to pool connections. Set connect_timeout lower than the Lambda timeout.
External API slow: add a per-call timeout in your HTTP client shorter than the Lambda timeout; implement retries with exponential backoff.
Cold start: increase memory (also increases CPU), use Provisioned Concurrency for latency-sensitive functions, use Lambda SnapStart for Java.
VPC cold start: Lambda in a VPC now uses pre-warmed ENIs (fixed in 2019), but verify you're in a subnet with available IPs and the security group allows outbound.
Timeout too low: simply increase timeout in the Lambda config (max 15 minutes) if the work genuinely takes longer.
Synchronous downstream calls: parallelize independent calls using asyncio.gather() (Python) or Promise.all() (Node.js).
55 more in the member app, with practice sets and your own marks. Join free