Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Just Enough Ops for Developers

Just Enough Ops for Developers

Originally presented at DjangoCon US 2022

Most developers don’t want to think about operations (aka Ops, DevOps, etc.) PaaS providers (Heroku, Fly, Render, etc.) do an awesome job of getting your app live on the internet, but there’s a lot to ops beyond just deployment.

This talk will answer the following questions:

* How much CPU and memory should I give my services?
* How do I know if the app is overallocated (costing too much money) or underallocated (slow/overloaded)?
* How can I make my app faster?
* Will autoscaling help me save costs?
* What about serverless?

If you’re a developer and want to run your applications successfully without deep DevOps knowledge, this talk is for you. It will help if you have some basic Django developer experience, but other than that, no specific knowledge is necessary!

Peter Baumgartner

October 18, 2022
Tweet

More Decks by Peter Baumgartner

Other Decks in Technology

Transcript

  1. About Me • Founder at Lincoln Loop — lincolnloop.com •

    Co-author of High Performance Django — highperformancedjango.com • Building AppPack — apppack.io
  2. Forget about 😴 • System security/hardening • Routing/networking • Secrets

    management • Deployments • Scaling how to, not when to • Process Management (systemd, docker, etc.) • Hardware failures
  3. Tuning Worker Count Each app is different • Start at

    double your CPU count • You can experiment with adding workers until • Not enough memory • Response times plateau or degrade
  4. 1 CPU / 1 minute 100ms response time = 6000

    requests 1s response time = 60 requests
  5. I/O (Input/Output) Examples • Reading/writing files • Database queries •

    Object storage (S3) • Search index queries • Third-party APIs
  6. • “Warm” code cache • Python objects • File processing/manipulation

    • Network sockets • File descriptors Memory (RAM) Ephemeral cache
  7. Django memory tips • Don’t read huge files into a

    string/byte object • Don’t process a huge queryset • Use Model.objects.iterator() • Use .values() to avoid creating a model instance • Use .only() to avoid loading large text fields
  8. Memory Leak Causes • Bug in C extension (no garbage

    collection) • Leaving file descriptors or network sockets open (use context managers) • Global objects (sometimes accidental)
  9. Worry about 😥 • Budgeting/variable costs • Cold starts •

    Database connections • Limitations (upload size, max duration) • Remote shell access Serverless
  10. Final Thoughts 🧐 • Get to know your application —

    “observability” • CPU usage • Memory usage • Response times • Error rates/uptime