FAQ
hi, Marco,

      how's your regexp look like, it must support JSESSIONID, PHPSESSID etc.


在 2012年4月30日星期一UTC+8下午6时25分44秒,Marco写道:
Hi Jesse,

I fixed it, as Peter said, the regexp contained in router/lib/router/
const.rb determines if sticky sessions are
needed, my problem was that my session id didn't match with the
regexp, I changed it and now the sticky sessions works perfectly,
until we finish implementing the new architecture with redis
persisting the session information...


Thank you very much.

On 25 abr, 00:01, Jesse Zhang wrote:
Hi Marco,
This is not strange. HTTP is
stateless<http://en.wikipedia.org/wiki/Stateless_protocol>,
to implement sessions (which are states) it has to be stored somewhere, and
the default behavior in PHP is that sessions are stored in memory on the
instance (memory allocated to the php executable or mod_php). This explains
why it is lost after your instance is down: if you pull your plug of your
server, sessions are lost.
Try using Redis as the session store.

Jesse






On Tue, Apr 24, 2012 at 2:52 PM, Marco wrote:
Hi Peter,
Thank you very much for your answer, I understand the performance
considerations but I would like to know why the sessions are lost
after the instances go down or up, is not supossed that the session is
attached to the corresponding instance? Is a strange behavior...
Anyway, I found a couple links for the people interested in
implementing sessions in PHP under CloudFoundry:
http://redis4you.com/articles.php?id=001&name=Redis+as+session+handle...
http://groups.google.com/group/redis-db/browse_thread/thread/47889905...
Greetings.
On 24 abr, 19:31, Pieter Noordhuis wrote:
Hi Marco,
Check this file for the regexp that determines if sticky sessions
are
needed: router/lib/router/const.rb
However, while sticky session works for a fairly static number of
instances it doesn't scale well. When instances go down and come up
again, the sessions are lost as well. Also: when you have a large
number of clients pounding on a small number of instances, scaling
the
number of instances up won't solve your problems as these clients
are
tied to the running instances.
A better solution for keeping sessions in this type of environment
is
to store them outside your app, in a service such as Redis. You can
easily bind a service to your app, and use some PHP module that
takes
care of moving sessions to Redis (not familiar with the PHP space,
but
I know they exist). This way, your instances can move around without
losing sessions.
Cheers,
Pieter
On Tue, Apr 24, 2012 at 2:17 AM, Marco wrote:
Hi all,
I have a multi-node setup with 2 DEAs, 2 Mongos, and one more node
with the rest of the components, all of them distributed in two
machines.
My problem is with a PHP application and the session information
among
multiple instances, the application works well on a single
instance,
but when I scale the app to multiple instances, the session stops
working, it works for a few minutes/actions, but after that I must
re-
login.
I see in this link:http://goo.gl/ItkzA, and precisely in this
answer,
that i must to do this for use the session affinity capabilities
of
CloudFoundry:
"For a web server to keep your sessions tied to the same backend,
it
needs to know which cookie keeps the session ID. For java, this is
(usually) JSESSIONID. For PHP this is PHPSESSIONID"
How can I tell the web server what cookie keeps my session ID?
What
are the best practices to use session variables in CloudFoundry?
Thanks in advance,
greetings.

Search Discussions

  • Andy Piper at Jul 9, 2013 at 12:04 pm
    I'd be interested in the fix - is this something that you could contribute
    back to the CF project?
    On Tuesday, 9 July 2013 08:06:04 UTC+1, K_James wrote:

    hi, Marco,

    how's your regexp look like, it must support JSESSIONID, PHPSESSID
    etc.


    在 2012年4月30日星期一UTC+8下午6时25分44秒,Marco写道:
    Hi Jesse,

    I fixed it, as Peter said, the regexp contained in router/lib/router/
    const.rb determines if sticky sessions are
    needed, my problem was that my session id didn't match with the
    regexp, I changed it and now the sticky sessions works perfectly,
    until we finish implementing the new architecture with redis
    persisting the session information...


    Thank you very much.

    On 25 abr, 00:01, Jesse Zhang wrote:
    Hi Marco,
    This is not strange. HTTP is
    stateless<http://en.wikipedia.org/wiki/Stateless_protocol>,
    to implement sessions (which are states) it has to be stored somewhere, and
    the default behavior in PHP is that sessions are stored in memory on the
    instance (memory allocated to the php executable or mod_php). This explains
    why it is lost after your instance is down: if you pull your plug of your
    server, sessions are lost.
    Try using Redis as the session store.

    Jesse






    On Tue, Apr 24, 2012 at 2:52 PM, Marco wrote:
    Hi Peter,
    Thank you very much for your answer, I understand the performance
    considerations but I would like to know why the sessions are lost
    after the instances go down or up, is not supossed that the session
    is
    attached to the corresponding instance? Is a strange behavior...
    Anyway, I found a couple links for the people interested in
    implementing sessions in PHP under CloudFoundry:
    http://redis4you.com/articles.php?id=001&name=Redis+as+session+handle...
    http://groups.google.com/group/redis-db/browse_thread/thread/47889905...
    Greetings.
    On 24 abr, 19:31, Pieter Noordhuis wrote:
    Hi Marco,
    Check this file for the regexp that determines if sticky sessions
    are
    needed: router/lib/router/const.rb
    However, while sticky session works for a fairly static number of
    instances it doesn't scale well. When instances go down and come up
    again, the sessions are lost as well. Also: when you have a large
    number of clients pounding on a small number of instances, scaling
    the
    number of instances up won't solve your problems as these clients
    are
    tied to the running instances.
    A better solution for keeping sessions in this type of environment
    is
    to store them outside your app, in a service such as Redis. You can
    easily bind a service to your app, and use some PHP module that
    takes
    care of moving sessions to Redis (not familiar with the PHP space,
    but
    I know they exist). This way, your instances can move around
    without
    losing sessions.
    Cheers,
    Pieter
    On Tue, Apr 24, 2012 at 2:17 AM, Marco <marcoala...@gmail.com>
    wrote:
    Hi all,
    I have a multi-node setup with 2 DEAs, 2 Mongos, and one more
    node
    with the rest of the components, all of them distributed in two
    machines.
    My problem is with a PHP application and the session information
    among
    multiple instances, the application works well on a single
    instance,
    but when I scale the app to multiple instances, the session stops
    working, it works for a few minutes/actions, but after that I
    must re-
    login.
    I see in this link:http://goo.gl/ItkzA, and precisely in this
    answer,
    that i must to do this for use the session affinity capabilities
    of
    CloudFoundry:
    "For a web server to keep your sessions tied to the same backend,
    it
    needs to know which cookie keeps the session ID. For java, this
    is
    (usually) JSESSIONID. For PHP this is PHPSESSIONID"
    How can I tell the web server what cookie keeps my session ID?
    What
    are the best practices to use session variables in CloudFoundry?
    Thanks in advance,
    greetings.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupvcap-dev @
postedJul 9, '13 at 7:06a
activeJul 9, '13 at 12:04p
posts2
users2

2 users in discussion

K_James: 1 post Andy Piper: 1 post

People

Translate

site design / logo © 2021 Grokbase