Sitemap
mattholland

Coding tips and resources for software engineers.

Follow publication

Member-only story

Managing Node.js - Express Sessions with Redis

6 min readJan 6, 2019

--

Article Summary: Learn how & why you should use Redis in-memory database storage for scalable Node.js / Express application session management (because the express-session store is not scalable).

It is red. Red it is. Redis it.

Overview

If you have ever created a local Node.js / Express application that uses session variables for data persistence (i.e. req.session), then you have probably used the express-session library that comes along with most boilerplate Express server configurations.

You may have also noticed that the express-session docs explicitly state the following:

Warning The default server-side session storage, MemoryStore, is purposely not designed for a production environment. It will leak memory under most conditions, does not scale past a single process, and is meant for debugging and developing.

If you have never been exposed to production application architecture, then this information might confuse you a bit. It is assuming that we probably have multiple instances of our application running (and perhaps on multiple boxes) under a load balancer like NGINX that is taking some kind of round-robin approach to fulfilling client requests.

With a setup like this, a typical user journey may comprise of the following:

--

--

mattholland
mattholland

Published in mattholland

Coding tips and resources for software engineers.

Matt Holland
Matt Holland

Written by Matt Holland

Software engineer based in Austin, TX, fueled by an endless stream of digital curiosity.

Responses (5)