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

Designing Fast & Scalable Python MicroServices with Django

Dinesh Joshi
February 22, 2018

Designing Fast & Scalable Python MicroServices with Django

This talk was presented at BayPIGGIES (Python User's Group in Bay Area) on Feb 22 2018. It describes a set of optimizations that one can go through in order to build fast & scalable MicroServices in Python using Django.

Dinesh Joshi

February 22, 2018
Tweet

More Decks by Dinesh Joshi

Other Decks in Programming

Transcript

  1. Outline • Reference App • Request & Response Pipeline •

    Middleware • ORM • Measuring Performance • Caching • Async Processing • Questions
  2. • Python 2 or 3 • Packages ◦ django (1.9+)

    ◦ django-restframework ◦ django-redis ◦ psycopg2 ◦ celery • Postgres • Redis Reference App Database (Postgres) Cache (Redis) Celery Tasks Queue Django App django App
  3. Request & Response Pipeline 1 WSGI Handler Middleware (Request) 2

    View 3 Request duration Middleware (Response) 4 Don’t Block!
  4. • Audit & Remove unnecessary middleware • Use ◦ Conditional

    GET middleware ◦ GzipMiddleware ◦ Cached Sessions Middleware: Accelerating Responses
  5. • Read heavy workloads • Boosts performance many-folds for cached

    responses • View Level or custom • Invalidation is complex Caching
  6. Request & Response Pipeline 1 WSGI Handler Middleware (Request) 2

    View 3 Request duration Middleware (Response) 4 Don’t Block!