In fact running our node application in production via:
will return this:
Warning: connection.session() MemoryStore is not designed for a production environment, as it will leak memory, and obviously only work within a single process.
Don't get any clearer than that! So what do we do. The options are various; google around to see the options available. node-plates has been configured to use:
- mongodb via connect-mongo
- redis via connect-redis
- couchdb via connect-couchdb
- memcached via connect-memcached
- in memory via connect
In order to configure a session we use session-konphyg which creates a sesssion store for us using cascading konphyg files.
konphyg will select at runtime the configuration file to use based on environment.
This allows us to; for example configure our app to use in memory session when in development; and one of the more scalable options above in production without the need for code-change.
Our get session store method above takes as argument a config file; below is our config file for production; which is using mongo:
Our session config file for development is configured in memory:
This post is part of a series of posts tagged under node-plates a boilerplate mobile/web application written in node.js, express, socket.io, mongooose, jquery.mobile & html 5.
You can grab this from github ->