Skip to Main Content
Talk Beginner

I Accidentally Built a Monitoring System While Trying to Debug Memory Leak

Proposal status is Rejected
Session Description

Three months ago, I was hunting down a memory leak in our Flask API that was driving me absolutely insane. The app would run fine for hours, then suddenly RAM usage would spike and everything would crash. Profilers showed nothing useful. Logs were useless. My manager kept asking "is it fixed yet?"


In my desperation, I started writing small Python scripts to track every possible metric I could think of - not because I knew what I was doing, but because I was running out of ideas. I tracked function call counts, database connection pools, even how many times certain variables were accessed. Most of it was probably stupid, but I was grasping at straws.


The weird thing is, those hacky little monitoring scripts I threw together in frustration actually became the most useful debugging tool our team has ever had. Not because they're sophisticated (they're definitely not), but because they were built by someone who was genuinely confused about what was happening in their own code.

This talk is the story of how desperation led to accidentally building something useful, and why sometimes the best tools come from not knowing what you're supposed to be doing. I'll show you the exact scripts I wrote (warts and all), the embarrassing assumptions I made, and how you can steal these ideas to debug your own mysterious problems - even if you have no idea what you're doing either.

Key Takeaways
  1. When Good Code Goes Bad
  2. A Flask app running fine — until a production-only memory leak appeared.
  3. Couldn’t reproduce locally. Slack pressure increasing.
  4. Realization: I didn’t actually know how to debug this properly.
  5. The Desperate Script
  6. Wrote watch_memory_like_a_hawk.py at 11 PM.
  7. Logged everything into a 47-column CSV.
  8. It found something — just not what I expected.
  9. Accidental Insight
  10. Spotted a pattern in messy logs.
  11. The leak wasn’t where I assumed.
  12. Learned what I should have been monitoring all along.
  13. From Panic to Practical Tools
  14. Built small debugging helpers:
  15. check_db_connection_weirdness.py
  16. who_is_calling_this_function_and_why.py
  17. memory_breadcrumbs.py
  18. Simple Python instrumentation that reduced uncertainty.
  19. Anti-Best Practices That Work
  20. Monitor assumptions, not just metrics.
  21. Instrument code when you don’t know the root cause.
  22. Sometimes print() beats proper logging.

Takeaways

  1. Practical Python monitoring patterns.
  2. Ready-to-adapt debugging scripts.
  3. Confidence to instrument code messily when needed.

I’ve previously delivered a talk at Pycon Us, DevConf India and regularly volunteer on CFP review panels for PyCon US and Europython for (2024–2025). I work on backporting and automation at Red Hat, have attended EuroPython in Past. My talk will focus on concrete, repeatable steps teams can apply immediately — not just theory.

References

Session Categories

Engineering practice - productivity, debugging

Which track are you applying for?

Cloud & DevOps

Speakers

Goutam Tiwari
Goutam Tiwari Software Maintenance Engineer | Red Hat

I am a Software Maintenance Engineer at Red Hat, where I work on backporting patches for various desktop subsystem tools to ensure security and stability in enterprise Linux environments. I have a keen interest in software and automation, and I actively contribute to open-source communities while learning and sharing knowledge. I’ve been a CFP reviewer for PyCon US, which helped me understand how to create and evaluate effective proposals. My work has been featured at DevConf India, and I’ve also been part of the GNOME Asia organizing team. I enjoy simplifying workflows and encouraging others to explore open-source technologies