DEV Community

akhil mittal
akhil mittal

Posted on

Scenario Based Debugging Interview Questions for SRE

Here are some scenario-based monitoring and debugging questions and answers specifically for an SRE (Site Reliability Engineer) profile. These scenarios will cover various aspects of monitoring, debugging, and incident management in cloud-native and distributed systems.

Scenario 1: High Latency in Production

Question:
You receive alerts indicating high latency for a critical API in production. How would you approach identifying the root cause and resolving it?

Answer:
Check Monitoring Dashboards:
Examine latency graphs in your monitoring tools (e.g., Prometheus, Grafana, Datadog).
Check for patterns: is the latency increasing gradually or spiking suddenly? Is it global or region-specific?
Review application metrics like request per second (RPS), memory usage, and CPU utilization.

Inspect Application Logs:
Check for errors or timeouts in logs using centralized logging tools (e.g., ELK, Splunk, or CloudWatch).
Look for slow query logs or issues with upstream/downstream services.

Network Latency:
Use tools like ping, traceroute, or mtr to check for network-level issues.
Ensure there are no DNS resolution delays (try switching DNS providers for testing).

Database Bottlenecks:
Review database slow queries or locks if the API is database-heavy.
Investigate if the database has hit connection limits or any scaling issues.

Scaling Issues:
Check if the infrastructure has auto-scaling set up and whether it triggered as expected.
If no auto-scaling, manually increase the number of application instances to handle increased load.

Fix:
Based on findings, you can apply fixes like query optimization, scaling resources, or deploying a hotfix for the API if code changes are required.

Post-Incident:
Create an incident post-mortem documenting the issue, resolution steps, and preventive measures.

Scenario 2: Disk Space Alert on a Critical Server

Question:
You receive a disk space alert on a critical production server. What steps will you take to resolve the issue without causing downtime?

Answer:
Identify Large Files:
Use commands like du -sh /* or ncdu to identify large directories and files.
Focus on logs, cache, or temporary files that may have grown unexpectedly.

Free Up Space:
Rotate or compress large log files (logrotate or gzip can help).
Clear unnecessary temporary files (/tmp, application cache, etc.).
Check for old Docker images/containers that can be pruned (docker system prune).

Check Backups:
Ensure backups are not stored locally. Offload them to a remote server (e.g., S3 or a backup service).

Monitor Continuous Growth:
Check if certain files (e.g., logs) are continuously growing. Set up temporary monitoring to track file growth in real time.

Long-Term Solution:
If the disk usage keeps increasing, increase the EBS volume size (for AWS) or move logs to a dedicated log aggregation solution.

Scenario 3: Out of Memory (OOM) Issues in a Microservices Application

Question:
Your Kubernetes pods are experiencing frequent Out of Memory (OOM) issues. How would you diagnose and fix this issue?

Answer:
Check Pod Memory Usage:
Use kubectl top pods or tools like Prometheus + Grafana to check which pods are consuming excessive memory.

Review Pod Resource Limits:
Verify if appropriate resource requests/limits have been set in your deployment.

Examine Application Logs:
Check for memory leaks or inefficient memory usage patterns in the application logs.

Heap Dumps & Profiling:
If the application is memory-intensive (like Java or Node.js), take a heap dump and analyze it with tools like jmap, JProfiler, or VisualVM to find memory leaks.

Autoscaling:
Ensure Horizontal Pod Autoscaling (HPA) is enabled if the traffic to the microservice varies. The HPA can increase pod count when memory or CPU thresholds are exceeded.

Fixes:
Based on the findings, apply appropriate fixes like optimizing memory usage in code, tuning garbage collection, or increasing pod memory limits.

Deploy and Test:
After fixing, redeploy the updated resources and monitor memory usage for stability.

Scenario 4: 502 Bad Gateway Error in a Load Balancer

Question:
Your web application is returning a 502 Bad Gateway error. How would you troubleshoot and resolve the issue?

Answer:
Check Load Balancer Logs:
Check your load balancer logs (e.g., ALB or NGINX) for more detailed error messages.
The 502 error typically indicates that the load balancer can’t reach the backend server, so check if the backend is healthy.

Verify Backend Health:
Use tools like curl or telnet to check if the backend servers are responding correctly.
Ensure that backend services are running and listening on the correct port.

Check Service Status:
Use kubectl get pods or your cloud provider’s dashboard to ensure that the backend service is up and running.
Review the health checks defined for your backend servers. If the health check threshold is too strict, adjust it.

DNS or Network Issues:
Ensure that there are no DNS misconfigurations or network issues between the load balancer and the backend.

Fix:
Depending on the findings, the fix could involve restarting services, fixing backend application issues, or modifying health check configurations.

Scenario 5: S3 Latency and High Read/Write Times

Question:
Your application that interacts with AWS S3 is experiencing high read/write latencies. How would you approach debugging and resolving the issue?

Answer:
Check S3 Metrics:
Check Amazon CloudWatch metrics for S3, including FirstByteLatency, TotalRequestLatency, 4xxErrorRate, and 5xxErrorRate.

Region-Specific Issues:
Ensure that your application and S3 bucket are in the same AWS region to minimize network latency.

Throttling:
If your application is making a large number of requests, ensure you’re not exceeding S3 rate limits. Use exponential backoff or S3 Transfer Acceleration to reduce latency.

Review S3 Settings:
If latency occurs when uploading large files, consider breaking files into multipart uploads.

Fix:
Optimize your application’s interaction with S3 (batching small requests, enabling Transfer Acceleration) and check for any network bottlenecks between your application and S3.

Scenario 6: No Logs for Application in Production

Question:
You’ve deployed an application to production, but no logs are showing up in your logging tool (e.g., CloudWatch, ELK). How do you troubleshoot and fix this?

Answer:
Check Logging Configuration:
Ensure the application is configured to send logs to the appropriate logging service (e.g., check logback.xml, logging.yaml, or logging.properties).

Log Permissions:
Ensure that the IAM role attached to your application has permission to write logs to the logging service.

Network Connectivity:
Ensure that the application has network access to the logging service endpoint (e.g., check VPC, security group settings).

Local Logs:
Check the local logs on the server or container (e.g., using docker logs) to verify that logs are being generated.

Fix:
Once the issue is identified (e.g., missing permissions or configuration), fix and redeploy the application to ensure logs are flowing correctly.

Scenario 7: High CPU Utilization on Production Servers

Question:
Your production server is experiencing consistently high CPU utilization, leading to slow application performance. How would you identify the root cause and mitigate it?

Answer:
Check Metrics:
Start by checking CPU utilization metrics via CloudWatch, Prometheus, or Datadog. Identify when the spike began and if it correlates with any recent changes (e.g., deployments).

Inspect Application Logs:
Review the application logs for any errors or exceptions that might indicate a loop or inefficient code.

Analyze Running Processes:
Use top or htop to identify which processes are consuming the most CPU.
If it’s a particular service, try restarting it to see if it reduces the load.

Investigate Application Code:
If the issue is isolated to certain processes, examine whether there's a memory leak, inefficient algorithm, or CPU-intensive operation.

Optimize or Scale:
If the application is under heavy load, either optimize the code (e.g., caching, reducing heavy computations) or scale the infrastructure horizontally or vertically (e.g., add more EC2 instances or move to a larger instance size).

Fix and Post-Mortem:
Apply the fix and monitor CPU usage. After resolving the issue, conduct a post-mortem and consider implementing auto-scaling or revising CPU limits.

Scenario 8: Application Crashing After Deployment

Question:
You’ve deployed a new version of your application, and it keeps crashing shortly after startup. What steps would you take to identify and resolve the issue?

Answer:
Check Logs:
Start by checking both the application logs and system logs (e.g., CloudWatch, ELK, Fluentd).
Look for any errors, exceptions, or stack traces that could indicate the cause of the crash.

Inspect Deployment Configuration:
Verify that the correct environment variables, config files, and secrets were provided during deployment.
Check if there are missing or invalid configurations that may cause the application to fail during startup.

Rollback Deployment:
If the issue cannot be fixed immediately, rollback to the previous stable version to minimize impact on users.

Examine Resource Allocation:
Check resource allocations (CPU, memory) and ensure the pod or container isn't getting OOMKilled due to insufficient memory limits.

Investigate Recent Code Changes:
Review the most recent code changes or dependency upgrades to identify if there was a bug introduced that caused the crash.
Test locally or in a staging environment to reproduce the issue.

Fix and Deploy:
Once the issue is identified and fixed, redeploy the application. Monitor it closely after the new deployment to ensure stability.

Scenario 9: Network Latency between Microservices

Question:
You’ve noticed increased latency between two microservices communicating within a Kubernetes cluster. How would you diagnose and resolve the problem?

Answer:
Check Service Mesh (if using):

If you're using a service mesh like Istio or Linkerd, check the sidecar proxies for any abnormal network latency or configuration errors.

Network Tools:
Use tools like curl, ping, or traceroute between the pods to identify if there are network-level issues.
Verify the pod’s network configuration and confirm that they are in the same namespace and can route traffic to each other.

DNS Resolution:
Ensure that there are no DNS resolution delays by testing direct IP communication to bypass DNS.
Check if CoreDNS or any DNS provider in the cluster is experiencing issues.

Service Load:
Check if the affected services are under heavy load (high CPU, memory) or if there are long-running queries slowing down the communication.
Inspect Kubernetes horizontal pod autoscaler (HPA) and ensure it's correctly scaling.

Network Policies:
Check for any Network Policies or firewall rules that may have been recently applied, limiting or delaying traffic between the microservices.

Resolution:
Apply the appropriate fix (e.g., update network policy, fix DNS, optimize service performance) and then monitor the services for reduced latency.

Scenario 10: Service Degradation During a High-Traffic Event

Question:
During a high-traffic event, your application’s performance degrades significantly. What strategies would you employ to stabilize the system and ensure it can handle the traffic?

Answer:
Review Auto-Scaling:
Check if your auto-scaling policies are working as expected. If not, increase the scaling limits manually to handle the surge in traffic.

Load Balancing:
Verify that the load balancer is distributing traffic evenly. If using AWS ELB/ALB, check for any bottlenecks in the request distribution.
Use sticky sessions sparingly and ensure there’s even distribution across instances.

Rate Limiting and Circuit Breakers:
Implement rate limiting at the API gateway to prevent a surge of requests from overwhelming backend services.
If a service is failing, use circuit breakers to stop it from cascading failures to other services.

Caching:
Review your caching layers (e.g., Redis, Memcached) to ensure they are functioning correctly. Increase cache TTL for frequently requested items to reduce load on the application/database.

Database Bottlenecks:
Check if your database is being overwhelmed. If using RDS, consider read replicas or enabling autoscaling for your database.
Optimize slow-running queries and ensure appropriate indexing is in place.

Fix and Monitor:
Once the system is stabilized, perform a thorough investigation into what caused the degradation and ensure proper capacity planning for future events.

Scenario 11: AWS EC2 Instance Failing Health Check

Question:
An EC2 instance in your AWS Auto Scaling group is failing health checks, causing it to terminate and get replaced. How would you identify the cause and fix it?

Answer:
Check CloudWatch Metrics:
Review CloudWatch metrics to check CPU, memory, and disk utilization for the failed EC2 instance. It may be under heavy load or resource-constrained.

Review System Logs:
Use the EC2 console to inspect the instance’s system logs and error messages. You can also check CloudWatch Logs for further insights (if logs are pushed there).

Inspect Application Logs:
If the failure is application-related, examine the application logs to find any errors or exceptions that occurred before the failure.

Check Health Check Configuration:
Verify if the health check is too strict or if the instance is taking too long to start. You might need to increase the health check grace period.
Ensure the instance is serving traffic on the correct ports.

Network Connectivity:
Ensure there are no networking issues preventing the instance from passing health checks, such as incorrect security group or NACL configurations.

Fix:
Apply necessary fixes, such as increasing resource limits, adjusting health check configurations, or fixing application bugs. Once applied, monitor the new instances for stability.

Scenario 12: S3 Bucket Suddenly Inaccessible

Question:
Your application suddenly loses access to an S3 bucket, causing a service outage. How would you investigate and resolve the issue?

Answer:
Check IAM Policies:
Review the IAM policy associated with the role or user accessing the S3 bucket. Ensure that the correct permissions (s3:GetObject, s3:PutObject) are in place.

S3 Bucket Policy:
Verify if the S3 bucket policy was modified or tightened recently, preventing access.
Check if there is a VPC Endpoint for S3, and ensure the bucket policy allows access from the right VPC or CIDR block.

Public Access Block:
Ensure that S3 Block Public Access settings have not been applied if your bucket needs public access.

Network Configuration:
If the application runs inside a VPC, check the VPC and security group settings to ensure it allows access to S3.

Check for Region-Specific Issues:
If the application and S3 bucket are in different regions, ensure there are no regional outages or cross-region access issues.

Fix:
Once the root cause (permissions, network, policy) is identified, apply the correct fix and restore access to the S3 bucket. Ensure proper monitoring and alerting is in place for future access issues.

Scenario 13: Kubernetes Pods Stuck in CrashLoopBackOff

Question:
You notice that one of your Kubernetes pods is stuck in CrashLoopBackOff state. How would you diagnose and resolve this?

Answer:
Check Pod Logs:
Use kubectl logs <pod-name> to inspect the logs and understand why the container is crashing.
Look for stack traces, exceptions, or errors in the logs indicating the root cause.

Inspect Container Lifecycle:
Use kubectl describe pod to examine the lifecycle events. Check if there are repeated restarts and see if the pod fails during the startup process.

Review Resource Limits:
Ensure the pod has sufficient CPU and memory requests/limits. If it’s getting killed due to out-of-memory (OOM) issues, you’ll see it in the pod description.

Environment Variables and ConfigMaps:
Check if the pod has the correct environment variables, secrets, and ConfigMaps mounted. Missing or misconfigured values could cause the pod to crash.

Debug with exec:
If the container starts briefly before crashing, you can try running kubectl exec -it <pod-name> -- /bin/sh to enter the container and investigate from inside.

Fix:
Based on the findings (e.g., fix misconfigurations, adjust resource limits, or patch a code issue), redeploy the pod and ensure it stabilizes.

These scenarios represent common challenges faced by SREs in production environments. Successfully diagnosing and resolving them requires familiarity with monitoring tools, cloud services (AWS, GCP, Azure), container orchestration (Kubernetes), and a systematic approach to incident management.

Top comments (0)