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→