Showing posts with label Kafka. Show all posts
Showing posts with label Kafka. Show all posts

Friday, 4 December 2026

Latest Solution Architecture interview Questions & Answers

Solution Architecture interviews often focus on  real world production challenges rather than theoritical concepts.

Interviewers want to understand how an architect approaches troubleshooting, scalability, performance, reliability and distributed system design.


 Below are five scenario based interview questions with practical answers.


Question 1. A spring boot API suddenly slows after deployment, but CPU usage is normal. How would you debug it?


Answer 1:

I would first compare the application metrics before and after deployment to identify what changed.

Since CPU usage is normal, I would investigate other possible bottlenecks:

1. Thread Pool: Check whether application threads are blocked or waiting for external services.

2. Database: Check slow SQL queries, connection pool exhaustion and database response time.

3. External APIs: Verify whether any dependent service is responsible slowly.

4. JVM: Analyze garbage collection activity, heap usage and memory pressure.

5. Network: Check network latency and connection timeouts.


I would use tools such as Spring Boot Actuator, Micrometer, Prometheus, Grafana and distributed tracing tools like Zipkin.


Question 2: Database connections keep increasing during peak traffic until requests start failing. What would you check?


Answer 2:

I would start by checking the database connection pool configuration, especially maximum pool size, connection timeout and idle connection settings.

Possible causes include:

1. Connection leaks: Connections are not properly released after database operations.

2. Long-running Queries: Slow queries hold connections for longer periods.

3. Pool Configuration: The maximum connection pool size may be too small for the workload.

4. Transaction Management: Transactions remain open longer than necessary.

5. Traffic Spike: Increased concurrent requests require more database connections.


In spring boot, I would inspect HikariCP metrics to monitor active, idle and pending connections.

I would also review database slow-query logs and application thread dumps.

The solution could involve fixing connection leaks, optimizing queries, tuning the connection pool and introducing caching or read replicas where appropriate.


Question 3: Kafka consumers are healthy, but message lag keeps growing. What could be wrong?

Answer 3:

Kafka consumer health doesn't necessarily mean that consumers are processing messages fast enough.

Consumer lag represents the difference between the latest available message offset and the offset processed by a consumer.

I would investigate the following:

1. Processing Time: Consumers may be taking too long to process individual messages.

2. Partition Count: A limited number of partitions can restrict consumer parallelism.

3. External Dependencies: Slow database operations or external API calls may delay message processing.

4. Consumer Configuration: Incorrect polling and batch-size configurations may reduce throughput.

5. Rebalancing: Frequent consumer group rebalancing can interrupt processing.


I would monitor consumer lag, processing latency, throughput and partition distribution.

Possible solutions include optimizing message processing, increasing partition count when appropriate, scaling consumers within partition limits and using batch processing.

  

Question 4: A retry mechanism starts creating duplicate payment transactions. How would you prevent this?

Answer 4:

This is a common problem in distributed systems where a request may succeed, but the response is lost due to a network failure.

The client assumes the transaction failed and retries the request, potentially creating a duplicate payment.


I would implement an idempotency mechanism.

Each payment request should contain a unique idempotency key. Before processing a payment, the application checks whether that key has already been processed.

If the transaction exists, the system returns the previously stored result instead of creating another payment. 

I would also enforce a unique database constraint on the idempotency key to prevent concurrent requests from creating duplicates.

Additionally, retry policies should use exponential backoff and distinguish between transient and permanent failures.


Question 5: One microservice becomes slow and slowly affects the entire system. How would you isolate the issue?

Answer 5:

This is a typical cascading failure scenario in a microservices architecture.

If one service becomes slow, other services waiting for its response may consume their threads and connections, eventually affecting the entire application.

I would introduce the following resilience mechanisms:

1. Timeouts: Configure appropriate timeouts for inter-service communication.

2. Circuit Breaker: Temporarily stop calling an unhealthy service.

3. Bulkhead Pattern: Isolate thread pools and connection pools so one service cannot consume all available resources.

4. Fallback: Return cached data or a controlled response when possible.

5. Rate Limiting: Control incoming traffic to prevent overloading services.


I would also use distributed tracing to identify the slow service and understand how latency propagates across service dependencies.

Tools such as Resilience4j, Prometheus and Grafana can help implement and monitor these mechanisms. 



  Thanks for reading!!