QA
Senior LevelREST APIs & Web Services

How do you execute long-duration Soak Testing using k6 or Locust to uncover memory leaks?

❓ Interview Prompt: Explain Soak Testing (Endurance Testing), k6 / Locust load scripts, running steady traffic for 24-48 hours, monitoring heap memory leaks, and connection pool exhaustion.

While Stress Testing tests peak traffic spikes over short intervals, Soak Testing (Endurance Testing) evaluates API stability under steady load over long durations (24 to 48 hours):

Critical Bottlenecks Uncovered:

1
Memory Leaks: Slow accumulation of uncleared references, open event listeners, or growing cached objects.
2
Database Connection Pool Exhaustion: Connection leaks that slowly consume available DB connections.
3
File Descriptor Leaks: Un-closed socket connections exhausting OS handles.

Code Implementation Example

javascript
// k6 Soak Testing Script (24-Hour Steady Load)
export const options = {
  stages: [
    { duration: '10m', target: 200 }, // Ramp up to 200 virtual users
    { duration: '24h', target: 200 }, // Hold steady 200 VUs for 24 hours!
    { duration: '10m', target: 0 },   // Ramp down
  ],
};

export default function () {
  http.get('https://api.example.com/v1/health');
}
💡Configuring a 24-hour k6 soak testing load execution script.
🎯 Interview Key Takeaway

Execute long-duration soak tests using k6 to uncover memory leaks and database connection pool exhaustion before production releases.

#Soak Testing#k6#Performance#Memory Leaks#Senior
Back to all REST APIs & Web Services Questions→

More REST APIs & Web Services Interview Questions

Beginner LevelREST APIs & Web Services

What is HTTP Method Idempotency and how do you implement Idempotency Keys for REST APIs?

Beginner LevelREST APIs & Web Services

What are standard HTTP Status Codes (200, 201, 204, 400, 401, 403, 404, 409, 429, 500, 503)?

Beginner LevelREST APIs & Web Services

What are HTTP Verbs (GET, POST, PUT, PATCH, DELETE) and when to use PUT vs PATCH?