My server runs nginx+tow tomcats+msm.

The nginx configration:
upstream tomcats {
server 127.0.0.1:9001;#tomcatA
server 127.0.0.1:9003;#tomcatB
}

Now imagine...

User1's first request will forward to tomcatA, so the session is hold
in tomcatA and store in memcached.
User1's second request will forward to tomcatB, so tomcatB will get
the session from memcached and keep the session in tomcatB.

Then tomcatA and tomcatB both hold the User1's session in memory.

Does that mean that each tomcat will hold every user's session in
memory? Is this will be a problem?

Thanks.

Search Discussions

  • Martin Grotzke at Dec 19, 2011 at 12:14 pm
    Hi,
    On 12/19/2011 11:40 AM, huang kun wrote:
    My server runs nginx+tow tomcats+msm.

    The nginx configration:
    upstream tomcats {
    server 127.0.0.1:9001;#tomcatA
    server 127.0.0.1:9003;#tomcatB
    }

    Now imagine...

    User1's first request will forward to tomcatA, so the session is hold
    in tomcatA and store in memcached.
    User1's second request will forward to tomcatB, so tomcatB will get
    the session from memcached and keep the session in tomcatB.

    Then tomcatA and tomcatB both hold the User1's session in memory.

    Does that mean that each tomcat will hold every user's session in
    memory? Is this will be a problem?
    If msm is configured with sticky="true" (the default) each tomcat will
    hold every user's session in memory. This should (only) be set if your
    loadbalancer (nginx) is configured to manage session stickyness.
    The main issue with a non-sticky LB but sticky tomcats is that there'll
    be stale session data once a tomcat is hit that has an old version of
    the session.

    If you want tomcats/msm to work in a non-sticky environment you should
    configure
    sticky="false"
    and consider if you need some kind of session locking (due to potential
    parallel requests changing session data), see also the msm attribute
    "lockingMode":
    http://code.google.com/p/memcached-session-manager/wiki/SetupAndConfiguration#Overview_over_memcached-session-manager_configuration_attributes

    Cheers,
    Martin
  • Rainer Jung at Dec 19, 2011 at 11:18 pm

    On 19.12.2011 13:14, Martin Grotzke wrote:
    Hi,
    On 12/19/2011 11:40 AM, huang kun wrote:
    My server runs nginx+tow tomcats+msm.

    The nginx configration:
    upstream tomcats {
    server 127.0.0.1:9001;#tomcatA
    server 127.0.0.1:9003;#tomcatB
    }

    Now imagine...

    User1's first request will forward to tomcatA, so the session is hold
    in tomcatA and store in memcached.
    User1's second request will forward to tomcatB, so tomcatB will get
    the session from memcached and keep the session in tomcatB.

    Then tomcatA and tomcatB both hold the User1's session in memory.

    Does that mean that each tomcat will hold every user's session in
    memory? Is this will be a problem?
    If msm is configured with sticky="true" (the default) each tomcat will
    hold every user's session in memory. This should (only) be set if your
    loadbalancer (nginx) is configured to manage session stickyness.
    But: *if* the LB manages stickyness, then each Tomcat will *not* hold
    all sessions, instead only the ones which were started on that Tomcat.
    Only when a session failover happens, e.g. because a Tomcat died or was
    stopped, the target Tomcat will need to additionally handle the sessions
    that failed over to it.

    And this is why you should use a sticky LB even if you have session
    redundancy. As long as there is not issue, you keep resource use low.
    Only when you actually need the failover the instances will need the
    additional ressources for the additional sessions.

    Right?

    Regards,

    Rainer
  • Martin Grotzke at Dec 20, 2011 at 6:41 am
    Right, Rainer, thanx for this clarification!

    Cheers,
    Martin

    Am 20.12.2011 00:18 schrieb "Rainer Jung" <rainer.jung@kippdata.de>:
    On 19.12.2011 13:14, Martin Grotzke wrote:

    Hi,
    On 12/19/2011 11:40 AM, huang kun wrote:

    My server runs nginx+tow tomcats+msm.

    The nginx configration:
    upstream tomcats {
    server 127.0.0.1:9001;#tomcatA
    server 127.0.0.1:9003;#tomcatB
    }

    Now imagine...

    User1's first request will forward to tomcatA, so the session is hold
    in tomcatA and store in memcached.
    User1's second request will forward to tomcatB, so tomcatB will get
    the session from memcached and keep the session in tomcatB.

    Then tomcatA and tomcatB both hold the User1's session in memory.

    Does that mean that each tomcat will hold every user's session in
    memory? Is this will be a problem?
    If msm is configured with sticky="true" (the default) each tomcat will
    hold every user's session in memory. This should (only) be set if your
    loadbalancer (nginx) is configured to manage session stickyness.
    But: *if* the LB manages stickyness, then each Tomcat will *not* hold all
    sessions, instead only the ones which were started on that Tomcat. Only
    when a session failover happens, e.g. because a Tomcat died or was stopped,
    the target Tomcat will need to additionally handle the sessions that failed
    over to it.

    And this is why you should use a sticky LB even if you have session
    redundancy. As long as there is not issue, you keep resource use low. Only
    when you actually need the failover the instances will need the additional
    ressources for the additional sessions.

    Right?

    Regards,

    Rainer

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupmemcached-session-manager @
categoriesmemcached
postedDec 19, '11 at 12:05p
activeDec 20, '11 at 6:41a
posts4
users3
websitememcached.org

People

Translate

site design / logo © 2022 Grokbase