Home Forums Chapter 8: Express in Production Cluster with session warning mesg

This topic contains 3 replies, has 2 voices, and was last updated by  Yaapa 1 year, 8 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #83

    gdbtek
    Participant

    If I use cluster with app.use(express.session());, I will get following warning mesg.

    Warning: connection.session() MemoryStore is not
    designed for a production environment, as it will leak
    memory, and will not scale past a single process.

    so does it means that I should not use session for cluster? Is there any workaround?

    Thanks

    #84

    Yaapa
    Keymaster

    MemoryStore is used for storing session data by default, which uses the app process’ memory. Since cluster processes can’t share session data, they will all be working with their own individual copies of session. This will result in a very erratic behavior from the app.

    The workaround is to use an external memory store like RedisStore or MongoStore. You can read the details on page 184-185.

    #89

    gdbtek
    Participant

    Thanks Yaapa!

    #96

    Yaapa
    Keymaster

    Most welcome!

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.