I’m using Node’s Express w/ Connect middleware. Connect’s memory session store isn’t fit for production:
Warning: connection.session() MemoryStore is not designed for a production environment, as it will leak memory, and obviously only work within a single process.
For larger deployments, mongo or redis makes sense.
But what is a good solution for a single-host app in production?
Spent the day looking into this. Here are the options I’ve discovered. Requests/second are performed via
ab -n 100000 -c 1 http://127.0.0.1:9778/on my local machine.maxAge)ttl)clear_intervalto be set to cleanup sessionsHere is the coffeescript I used for cookieSession:
Here is the coffeescript I use for redis:
Here is my coffeescript for mongo:
Now of course, the remote redis and mongo databases will be slower than their local equivalents. I just couldn’t get the local equivalents working, especially considering the installation and maintenance time for me was far more than what I was willing to invest when compared with hosted remote alternatives, something I feel is true for others too hence why these hosted remote database services exist in the first place!
For local database benhmarks, see @Mustafa’s answer.
Happy for someone to edit this answer to add their local database benchmarks to the mix.