Your Python app's latency spikes every few minutes. Prometheus shows the spikes line up with high GC activity. What do you investigate?
AdvancedScenarioTesting, CI/CD, packaging & services
Answer
Situation read → Garbage collection pauses or memory pressure.
What I'd do →
- Check the
python_gc_collections_totalandprocess_resident_memory_bytesmetrics thatprometheus_clientexports by default. - Profile allocations with
tracemallocsnapshots ormemrayin staging. - Look for large object graphs created per request (caching whole API responses, huge dict copies).
- Tune
gc.freeze()after startup for pre-fork servers, or adjust thresholds, only after fixing allocation hot spots. - Check CPU throttling from container limits, which can masquerade as GC pauses.
Why → Allocation reduction fixes GC pauses; tuning only hides them.
Interview tip → Mention CPU throttling; it is a common confounder in containers.
More on Testing, CI/CD, packaging & services
You join a team whose Python automation repo has no tests. Where do you start?BeginnerYour pytest suite takes 12 minutes. How do you speed it up?IntermediateA test passes locally but fails in CI only when run with the rest of the suite. What do you suspect?IntermediateYou want a reusable CI pipeline for 15 Python tool repos. What goes in it?IntermediateYour Python Docker image is 1.1 GB. How do you shrink it?IntermediateYou want to distribute an internal CLI to 200 engineers. What are your options?Intermediate