Accelerating and Enhancing Django with Redis

Summary

This tutorial introduces Redis, an in-memory key-object NoSQL datastore. We discuss out-of-the-box ways Redis can help improve the performance of your Django deployments, ways that using Redis instead of SQL for some data management can accelerate your apps, and more advanced and unconventional uses for Redis to solve real-time and big-data problems.

Description

Getting your Django app to a v1.0 release means focusing on function and user experience before prematurely focusing on optimization. But once it's off the ground, the Redis key-object store provides a versatile and functional way to take your app to the next level of performance and function with minimal engineering.

Redis is an in-memory key-object database that can perform standard operations on simple values, lists, sets, hash maps, and scored sets with incredible efficiency. While it cannot and should not replace SQL for schema-defined, persistent data storage, it can provide dramatically faster operational efficiency for volatile, temporary, or rapidly changing data with minimal coding required.

This talk begins by introducing Redis, its basic featureset, and the data types and operations it supports. We'll cover some high-level guidelines and strategies for identifying where Redis may be an appropriate performance- enhancing solution. We then cover the out-of-the-box ways that Redis can improve a Django application as a cache, session store, Celery broker, and more. We'll then proceed to more advanced usage possibilities, implementing a real-time websocket based messaging solution, scripting within Redis using its embedded Lua interpreter, and connecting Redis to PostgreSQL using Foreign Data Wrappers to efficiently blend SQL tables with Redis data.

By the end of the presentation, you should be able to use all of the data- structures offered by Redis, to identify opportunities within you codebase that Redis may offer simple but dramatic efficiency improvements, and to envision how advanced Redis usage may bring new and cutting-edge functionality to your project.

Redis was developed by Salvatore Sanfilippo and Pieter Noordhuis, who are both supported by VMWare to develop the database full-time. Redis has excellent Python bindings developed by Andy McCurdy.