A critical Flipkart microservice deployed on Kubernetes is experiencing intermittent network latency. How would a DevOps Engineer diagnose and troubleshoot this issue?

Flipkart DevOps Engineer 3–5 Years Networking

Diagnosing intermittent network latency in a Kubernetes microservice requires a systematic approach, starting from the application layer and drilling down to the underlying infrastructure. First, I would confirm the issue’s scope and characteristics using monitoring tools like Prometheus and Grafana. I would check application logs for unusual delays, failed requests, or timeouts that correlate with the reported latency. Examining service mesh metrics, if applicable (e.g., Istio or Linkerd), would reveal latency between service calls. This initial step helps determine if the problem is truly network-related or an application-level bottleneck.

Kubernetes Networking Layers

Next, I would investigate the Kubernetes networking stack. I would start with the pod itself, using `kubectl exec` to run basic network diagnostic commands like `ping`, `traceroute`, or `netstat` from within the affected pod to other pods, services, or external endpoints. This helps identify if the latency is internal to the cluster or when communicating externally. I would inspect Kubernetes Network Policies that might be inadvertently rate-limiting traffic or causing dropped connections. Then, I would examine the Kubernetes Service and Ingress configurations to ensure they are correctly routing traffic and not introducing bottlenecks. Issues like misconfigured load balancers or insufficient resources allocated to Ingress controllers can cause latency.

Best practice

A best practice for troubleshooting such issues is to establish a robust observability stack from the outset, including comprehensive metrics, logs, and traces. Leveraging tools like `kubectl top node` and `kubectl top pod` provides quick insights into resource utilization. For network-specific diagnostics, `tcpdump` can capture packet traces, while `netstat -s` or `ss -s` provide detailed socket statistics. Correlate findings across these data sources to build a complete picture. Implementing synthetic monitoring, where automated checks continuously test network paths and response times, helps catch intermittent issues before users report them.

Edge case interviewers probe for

Interviewers often probe for understanding of edge cases like DNS resolution issues within the cluster, which can manifest as intermittent timeouts or delays. This might involve checking `kube-dns` or CoreDNS pod health and configuration. Another edge case is kernel-level network tuning on the node, such as `net.core.somaxconn` or `net.ipv4.tcp_tw_reuse`, which can impact connection handling under high load. Furthermore, understanding how CNI plugins (e.g., Calico, Flannel, Cilium) allocate IPs and handle network traffic, including potential bugs or resource contention within the CNI itself, demonstrates deeper networking knowledge.

Common mistake

A common mistake is immediately blaming the network without sufficient data, or conversely, focusing too narrowly on the application code without considering the underlying infrastructure. Another error is not systematically narrowing down the problem scope. For example, failing to first determine if the latency is between pods on the same node, different nodes, or external traffic before diving into complex configurations. Neglecting host-level network issues on the Kubernetes worker nodes, such as saturated NICs, misconfigured firewall rules (`iptables`), or overloaded network switches, can also lead to misdiagnosis.

What the interviewer is checking

The interviewer is checking your systematic troubleshooting methodology, depth of knowledge in Kubernetes networking (including CNI, Services, Network Policies), proficiency with diagnostic tools, and ability to think critically across multiple layers of the stack. They want to see if you can isolate the problem effectively, rule out common causes, and consider less obvious scenarios. Your understanding of observability principles and how to apply them in a distributed environment is also key.

Imagine sending a letter (your data request) through a very complex, automated postal service (your Kubernetes cluster). Your letter starts at your desk (your microservice pod) and needs to get to a specific recipient (another service or database). This postal service has many sorting offices (nodes), delivery vans (network links), and specialized clerks (CNI plugins) who manage addresses. When your letter takes a long time to arrive intermittently, it’s like a delay in this postal system. It could be that your local clerk is slow, the van route is congested, or a specific sorting office is overwhelmed.

To find the problem, you would start by checking your outgoing mailbox (pod’s network interface) to see if the letter leaves quickly. Then you might check if the local van (node’s network) is moving well. You would also check the various sorting offices (Kubernetes services or ingress) to see if letters are piling up there. You would use different tools, like asking postal workers (monitoring tools) where the letter is getting stuck, or even sending a test letter with a tracker (ping/traceroute) to map its journey, to pinpoint exactly which part of the complex postal system is causing the intermittent delays.

Why interviewers ask this

Interviewers ask this to gauge your practical problem-solving skills in a complex, distributed environment. They want to see if you can approach a production issue systematically, identify potential culprits across different layers, and demonstrate proficiency with diagnostic tools relevant to Kubernetes and networking.

What a strong answer signals

A strong answer signals a deep understanding of Kubernetes architecture, networking fundamentals, and an ability to apply structured troubleshooting. It shows you can prioritize, use data to drive decisions, and consider both application and infrastructure perspectives, which is crucial for a senior DevOps role.

Common follow-ups

  • How would you prevent this issue from recurring in the future?
  • What if the latency only occurred during specific times of the day or after a deployment?
  • How would you integrate network performance monitoring into your CI/CD pipeline for proactive detection?

Advanced variation

An advanced variation might involve diagnosing latency in a multi-cluster, multi-cloud setup, or specifically within a service mesh where advanced routing and policy enforcement are involved. This would require knowledge of cross-cluster communication, global load balancing, and service mesh specific observability tools.

Consider a scenario where Flipkart’s product catalog microservice, deployed on Kubernetes, intermittently experiences 500ms latency spikes when fetching data from the backend database service. Initial checks show the database is healthy and has low latency itself. Upon investigation, a recent Kubernetes Network Policy change was found to have introduced a rule that inadvertently throttled egress traffic from the product catalog pods to specific IP ranges, including the database service’s private IP. Reverting or correcting the network policy immediately resolved the intermittent latency, highlighting how even subtle network configuration changes can have significant performance impacts.

diagnose_k8s_network.sh
# Example script to diagnose network latency from within a Kubernetes pod

POD_NAME="my-microservice-pod-abcdef"
NAMESPACE="production"
TARGET_IP="10.0.0.42"  # Example: IP of a database or another service
TARGET_DNS="my-db-service.production.svc.cluster.local"

# 1. Check basic connectivity and latency to a target IP
echo "--- Pinging target IP from pod ---"
kubectl exec "${POD_NAME}" -n ${NAMESPACE} -- ping -c 5 ${TARGET_IP}

# 2. Trace the network path (requires iputils or similar in pod image)
echo "--- Traceroute to target IP from pod ---"
kubectl exec ${POD_NAME} -n ${NAMESPACE} -- traceroute ${TARGET_IP}

# 3. Check DNS resolution for a service (if issues are DNS related)
echo "--- Digging target DNS from pod ---"
kubectl exec ${POD_NAME} -n ${NAMESPACE} -- dig ${TARGET_DNS}

# 4. List open network connections and their states
echo "--- Netstat -tulpn from pod ---"
kubectl exec ${POD_NAME} -n ${NAMESPACE} -- netstat -tulpn

# 5. Check network interface statistics on the node (requires SSH access to node)
echo "--- Checking node network interface stats (run on affected node) ---"
# ssh user@node-ip "ip -s link show eth0" 
# ssh user@node-ip "sar -n DEV 1 5" 
# ssh user@node-ip "iptables -L -v -n"

# 6. Check Kubernetes Network Policy (example: get all network policies)
echo "--- Checking Kubernetes Network Policies in namespace ---"
kubectl get networkpolicy -n ${NAMESPACE} -o yaml
Client Request K8s Ingress/Load Balancer K8s Service K8s Pod (Microservice) Node Network CNI Plugin Potential Latency Point Potential Latency Point Client Ingress Controller Service Pod/Container (Application) Kubernetes Node Host OS CNI Network Interface
  1. 1Start diagnosis by validating the problem’s scope and characteristics using existing monitoring data and logs.
  2. 2Systematically troubleshoot from the application layer down to the host level, using tools like `kubectl exec`, `ping`, and `traceroute`.
  3. 3Investigate Kubernetes-specific networking components, including Network Policies, Services, Ingress, and the CNI plugin.
  4. 4Do not overlook host-level network health on the Kubernetes worker nodes, checking `iptables` rules and interface statistics.
  5. 5A robust observability stack, including metrics, logs, traces, and synthetic monitoring, is crucial for proactive detection and efficient diagnosis of intermittent issues.