I am using AWS Elastic Beanstalk with EC2 servers behind an elastic load balancer (ELB).
I have sticky sessions on ELB because this is the only way I can get django user sessions to work correctly. However, during peak traffic, this causes problems because the ELB no longer distributes each incoming request evenly. Usually this overloads 1 server, like mini DDOS.
What I would like to do is use server-side user sessions, where user authentication information is stored in my Redis cache. I tried setting SESSION_ENGINE to a lot of things like:
SESSION_ENGINE = 'redis_sessions.session' SESSION_ENGINE = 'django.contrib.sessions.backends.cache' SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'
Then, when I disconnect sticky sessions, I canβt log in because requests end on different servers where some requests are authenticated and others are not. Those that are not redirect me back to the login page.
Here are some other relevant settings that I have:
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', ..., )
What am I doing wrong? Thank you very much.