Django user sessions with AWS Load Balancer stickiness turned off
<p>I'm using AWS Elastic Beanstalk with EC2 servers behind an Elastic Load Balancer (ELB).</p>

<p>I have "sticky sessions" on the ELB enabled because that's the only way I can get django user sessions to work correctly. However, during times of peak traffic, this causes problems because the ELB no longer distributes each incoming request evenly. This usually overloads 1 server like a mini DDOS. </p>

<p>What I would like to do is use server-side user sessions where user authentication information is stored in my Redis cache. I've tried setting <code>SESSION_ENGINE</code> to numerous things like:</p>

<pre><code>SESSION_ENGINE = 'redis_sessions.session' 
SESSION_ENGINE = 'django.contrib.sessions.backends.cache'
SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
</code></pre>

<p>Then when I turn sticky sessions off, I am unable to login because the requests end up going to different servers where some requests are authenticated and others are not. The ones that are not, redirect me back to the login page. </p>

<p>Here are some other relevant settings I have:</p>

<pre><code>INSTALLED_APPS = (
    ...,
    'django.contrib.sessions',
    ...,
)
MIDDLEWARE_CLASSES = (  
    ...,
    'djangosecure.middleware.SecurityMiddleware',
    ...,
    'django.contrib.sessions.middleware.SessionMiddleware',
    ...,
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    ...,
)
</code></pre>

<p>What am I doing wrong? Many thanks.</p>