title: Nodejs session management comparing to java server session management
body: <p>Consider a java web application like <code>tomcat</code>, which handles <code>sessions</code>. The <code>sessions</code> are stored in memory (and could be <code>serialized</code> to hard disk during server restart).</p>
  
  <p>For a <code>nodejs</code> application, which does not handle session by it self, you can develop session by using some lib called <code>expressjs/session</code> hosted at <a href="https://github.com/expressjs/session" rel="nofollow noreferrer">https://github.com/expressjs/session</a>. While reviewing the <code>expressjs/session</code> documents you see this warning:</p>
  
  <blockquote>
    <p><strong>Warning:</strong> The default server-side session storage, <code>MemoryStore</code>, 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.</p>
  </blockquote>
  
  <p>To me storing the sessions in memory is what is currently done in java web applications, without any problem.</p>
  
  <p>Now my question is:</p>
  
  <ol>
  <li>Is storing session in memory a bad practice at all?!</li>
  <li>If losing session during server restart and performance is not my concern (because of my application scale), is storing session in memory still a bad practice in <code>nodejs</code>?! (Please see <a href="https://stackoverflow.com/questions/33280176/what-is-the-use-of-a-session-store">What is the use of a session store?</a>)</li>
  </ol>