Tuesday 1:30 p.m.–2:20 p.m.

Performant Django

Ara Anjargolian

Audience level:

Intermediate

Description

Since the days of version 1.0, the Django community has added countless features that address performance pain points; everything from cached template loaders to prefetch_related(), the staticfiles app to django-debug-toolbar. But how do you use these tools to make your site fast? In this talk we take a meandering survey through the Django/Python performance landscape.

Abstract

Since the days of version 1.0, Django itself and the Django community has added countless features that address performance and scalability pain points; everything from cached template loaders to prefetch_related(), the staticfiles app to django-debug-toolbar. But when and how do you use these tools to make your site fast? In this talk we take a meandering survey through the Django/Python performance landscape. We will cover tips, tricks and best practices in addressing front-end and back-end performance.

Back-End Performance

To address back-end performance begins we begin with a profile. From there we present different approaches to solving the major hotspots in modern web applications. For DB dominated profiles, we will explore explore only(), select_related(), prefetch_related() down to lower-level approaches like db_index and denormalization. For non-DB Python dominated profiles we look at memoization and caching as two approaches towards optimizing away long-running Python code. We will also touch on more involved optimization techniques like Cython.

Front-End Performance

While backend performance is often the center of performance optimization efforts, in fact 80-90% of end-user response time is spent on the front-end. Front-end performance work is more systematic in nature and less specific to any particular webpage or view. Here we will discuss Django's solutions for implementing front-end performance best practices. We will consider far futures caching of static elements, bundling of CSS and JS files, JS/CSS compression, CDNs and static file hosting and data URIs and more.