Search code examples
djangopostgresqlredisdjango-redis

Should Redis for Django Session Storage Go on Separate Server?


I'm building a Django application that uses PostgreSQL for data storage and Redis with Django Redis Cache for Django session storage. I'm also using RQ for asynchronous job queues. I've built the application so that my PostgreSQL database resides on a separate server. I have two questions:

  1. Should Redis and Django Redis Cache both be installed on my Django web server since they are handling session storage or should I install them on my database server since they are providing database-like functionality?
  2. Should RQ be installed on the web server or the database server? I would think it should be installed on the same server as Redis but I'm not sure.

Thanks.


Solution

  • Assuming you've really got just two machines to work with, I'd say Redis on the web server and RQ on the database server.

    The cache close to its consumer and the non-latency critical RQ elsewhere.

    However, if you've got an in-memory cache before any call to Redis then I'd say to put Redis on the db server too so that you free up all available cpu cycles for the web server.

    Of course, in an ideal world each of these services would be on seperate hosts that you could resize acordingly (thinking amazon style seamless upgrade). To start with they could even be on the same physical hosts but identified using suitable host aliases to avoid building too many hosting assumptions into your code.

    Completely agree that docker and ansible are great ways to go if you can.