ā€œDoes Django scale?ā€
An introduction to Scalability
Python Barcelona
David Arcos
Hi! I’m David
ā—
I’m a backend developer specialized in distributed systems,
scalability and security
ā—
>10 years building SaaS platforms in different sectors
ā—
CTO at Lead Ratings
– SaaS solution that uses Machine-Learning algorithms to
predict business metrics (conversion, billing, churn...)
ā—
Associate professor at ESADE
– Teaching ā€œCloud Computingā€
ā—
PyBCN meetup assistant since 2008, organizer since 2013
1) Does Django Scale?
Questions
https://stackoverflow.com/questions/886221/does-django-scale
https://docs.djangoproject.com/en/dev/faq/general/#does-django-scale
1) Does Django Scale? YES
2) What is Scalability?
Questions
Scalability
ā€œThe potential of a system
to be enlarged to accommodate
a growing amount of workā€
ā€œA Word on Scalabilityā€ (2006)
ā€œA service is said to be scalable if when
we increase the resources in a system,
it results in increased performance in a
manner proportional to resources addedā€
- Werner Vogels (Amazon CTO)
https://www.allthingsdistributed.com/2006/03/a_word_on_scalability.html
Will it scale?
An algorithm/protocol/system does scale, if it
is suitably efficient and practical when applied
to large situations. In example:
– a large input data set
– a large number of outputs or users
– a large number of participating nodes
If it fails when increasing, it doesn’t scale.
Performance != Scalability
ā—
Performance is a quality metric:
– ā€œThe time it takes to execute one requestā€
ā—
Scalability:
– The ability to maintain that performance, under
increasing load
– Or: increase performance when adding resources
Where is the state?
ā—
Scaling is much easier if:
– The app servers are stateless
– The database keeps the state
ā—
So:
– Vertical scalability on (stateful) db servers
– Horizontal scalability on (stateless) app servers
Vertical / horizontal scaling
Vertical scaling
ā—
Scale up/down: add/remove resources to a
single node
– Adding more power (faster CPU, more CPUs, more
memory, a bigger disk…) to an existing machine
ā—
Very common on databases (stateful systems)
ā—
Easier… when possible
Vertical scaling… but...
ā—
But:
– There are hardware limits
ā—
RDS current limit of 488 GiB of memory (db.r4.16xlarge)
– Diminishing returns
ā—
At some point, the level of benefits gained is less than
the amount of money invested.
– Involves downtime
ā—
Keep a hot spare!
ā—
RDS Multi A-Z has a ā€œstandbyā€ replica with automatic
failover
Horizontal scaling
ā—
Scale out/in: add/remove nodes to a system
– Adding new computers to a cluster
ā—
Very common on (stateless) web servers
ā—
High availability
– doesn’t matter if some nodes crash
ā—
Cheaper (HW is cheap, VMs are cheap)
Horizontal scaling.. but...
ā—
But:
– Architecture must support it
ā—
Keep the state in external db!
– Management overhead
ā—
Automate it!
ā—
Sysadmin operations must be treated as software + config
1) Does Django Scale? YES
2) What is Scalability?
3) What is Django?
Questions
ā€œThe web framework for
perfectionists with deadlinesā€
https://www.djangoproject.com
Who uses Django?
ā—
Instagram
ā—
Pinterest
ā—
Spotify
ā—
Disqus
ā—
Bitbucket
ā—
Mozilla Firefox
ā—
Dropbox
ā—
Open Stack
ā—
NASA
ā—
The Washington Post
ā—
National Geographic
ā—
The Onion
ā—
Eventbrite
ā—
Prezi
ā—
Reddit Gifts
ā—
Open Knowledge
Foundation
ā—
MacArthur Foundation
DRF: Django REST framework
https://www.django-rest-framework.org
ā€œA powerful and flexible toolkit for building Web APIsā€
http://www.celeryproject.org
Celery: Distributed Task Queue
Other Python web frameworks
1) Does Django Scale? YES
2) What is Scalability?
3) What is Django?
4) How to scale Django?
Questions
How to Scale Django?
ā—
Measure first, find bottlenecks
– Rinse and repeat
ā—
Focus on database performance
– Indexes, queries, replicas...
ā—
Cache all the things!
– Excellent cache documentation
ā—
Run slow tasks in async workers
– (when possible)
ā€œHigh Performance Djangoā€ book
https://highperformancedjango.com
1) Does Django Scale? YES
2) What is Scalability?
3) What is Django?
4) How to scale Django?
Questions
Thanks for attending!
At Lead Ratings we are looking for:
– Python Developers
– Data Engineers
– Data Scientists
Questions?

Does Django scale? An introduction to Scalability

  • 1.
    ā€œDoes Django scale?ā€ Anintroduction to Scalability Python Barcelona David Arcos
  • 2.
    Hi! I’m David ā— I’ma backend developer specialized in distributed systems, scalability and security ā— >10 years building SaaS platforms in different sectors ā— CTO at Lead Ratings – SaaS solution that uses Machine-Learning algorithms to predict business metrics (conversion, billing, churn...) ā— Associate professor at ESADE – Teaching ā€œCloud Computingā€ ā— PyBCN meetup assistant since 2008, organizer since 2013
  • 3.
    1) Does DjangoScale? Questions
  • 4.
  • 5.
  • 6.
    1) Does DjangoScale? YES 2) What is Scalability? Questions
  • 7.
    Scalability ā€œThe potential ofa system to be enlarged to accommodate a growing amount of workā€
  • 8.
    ā€œA Word onScalabilityā€ (2006) ā€œA service is said to be scalable if when we increase the resources in a system, it results in increased performance in a manner proportional to resources addedā€ - Werner Vogels (Amazon CTO) https://www.allthingsdistributed.com/2006/03/a_word_on_scalability.html
  • 9.
    Will it scale? Analgorithm/protocol/system does scale, if it is suitably efficient and practical when applied to large situations. In example: – a large input data set – a large number of outputs or users – a large number of participating nodes If it fails when increasing, it doesn’t scale.
  • 10.
    Performance != Scalability ā— Performanceis a quality metric: – ā€œThe time it takes to execute one requestā€ ā— Scalability: – The ability to maintain that performance, under increasing load – Or: increase performance when adding resources
  • 11.
    Where is thestate? ā— Scaling is much easier if: – The app servers are stateless – The database keeps the state ā— So: – Vertical scalability on (stateful) db servers – Horizontal scalability on (stateless) app servers
  • 12.
  • 13.
    Vertical scaling ā— Scale up/down:add/remove resources to a single node – Adding more power (faster CPU, more CPUs, more memory, a bigger disk…) to an existing machine ā— Very common on databases (stateful systems) ā— Easier… when possible
  • 14.
    Vertical scaling… but... ā— But: –There are hardware limits ā— RDS current limit of 488 GiB of memory (db.r4.16xlarge) – Diminishing returns ā— At some point, the level of benefits gained is less than the amount of money invested. – Involves downtime ā— Keep a hot spare! ā— RDS Multi A-Z has a ā€œstandbyā€ replica with automatic failover
  • 15.
    Horizontal scaling ā— Scale out/in:add/remove nodes to a system – Adding new computers to a cluster ā— Very common on (stateless) web servers ā— High availability – doesn’t matter if some nodes crash ā— Cheaper (HW is cheap, VMs are cheap)
  • 16.
    Horizontal scaling.. but... ā— But: –Architecture must support it ā— Keep the state in external db! – Management overhead ā— Automate it! ā— Sysadmin operations must be treated as software + config
  • 17.
    1) Does DjangoScale? YES 2) What is Scalability? 3) What is Django? Questions
  • 18.
    ā€œThe web frameworkfor perfectionists with deadlinesā€ https://www.djangoproject.com
  • 19.
    Who uses Django? ā— Instagram ā— Pinterest ā— Spotify ā— Disqus ā— Bitbucket ā— MozillaFirefox ā— Dropbox ā— Open Stack ā— NASA ā— The Washington Post ā— National Geographic ā— The Onion ā— Eventbrite ā— Prezi ā— Reddit Gifts ā— Open Knowledge Foundation ā— MacArthur Foundation
  • 22.
    DRF: Django RESTframework https://www.django-rest-framework.org ā€œA powerful and flexible toolkit for building Web APIsā€
  • 23.
  • 24.
    Other Python webframeworks
  • 25.
    1) Does DjangoScale? YES 2) What is Scalability? 3) What is Django? 4) How to scale Django? Questions
  • 26.
    How to ScaleDjango? ā— Measure first, find bottlenecks – Rinse and repeat ā— Focus on database performance – Indexes, queries, replicas... ā— Cache all the things! – Excellent cache documentation ā— Run slow tasks in async workers – (when possible)
  • 27.
    ā€œHigh Performance Djangoā€book https://highperformancedjango.com
  • 28.
    1) Does DjangoScale? YES 2) What is Scalability? 3) What is Django? 4) How to scale Django? Questions
  • 29.
    Thanks for attending! AtLead Ratings we are looking for: – Python Developers – Data Engineers – Data Scientists
  • 30.