Why Should I use Redis when I have PostgreSQL as my database for Django?

45,220

Redis is a key-value storage system that operates in RAM memory, it's like a "light database" and since it works at RAM memory level it's orders of magnitude faster compared to reading/writing to PostgreSQL or any other traditional Relational Database. Redis is a so-called NoSQL database, like Mongo and many others. It can't directly replace PostgreSQL, you still want permanent storage, but it works along with Relational Databases as an alternate storage system. You can use Redis if your IO operations start getting expensive and it's great for quick calculations and key-based queries.

You can include it in your Django/Python project with a wrapper, for example redis-py.

Redis is very simple to install and use, you can check the examples at redis-py. Redis is independent from any Relational Database, that way you can use it for caching, calculating or storing values permanently and/or temporarily. It can help reduce querying to PostgreSQL, in the end you can use it the way you want and take advantage from it to improve your app/architecture.

This similar question can help you Redis with Django

Share:
45,220
deadlock
Author by

deadlock

I specialize in Django & PostgreSQL. I'm self taught and most of my knowledge comes from places like Stackoverflow and Serverfault.

Updated on January 30, 2020

Comments

  • deadlock
    deadlock about 4 years

    I've have a Django app that's currently hosted up on Amazon's EC2 service. I have two machines, one with the Django app and the other with my PostgreSQL database. So far it has been rock solid.

    Many sources claim I should implement Redis into my stack, but what would be the purpose of implementing Redis with Django and Postgresql? How can I implement Redis in my Django code for example?

    How can I use it with PostgreSQL?

    These are all the questions I've been trying to find answers to so I came here hoping to get answers from the biggest and the best. I really appreciate any answers.

    Thank You