For dev I'm using Rack::Session::Pool and use that to issue a session
ID and share it between the browser and server via a cookie. On the
server Rack::Session::Pool stores the data in memory.
This is not compatible with a production environment with multiple
dynos/servers. Since Heroku doesn't do sticky sessions a user that
gets issued a session cookie on Dyno1 is fine as long as his requests
hit Dyno1 but as soon as he hits Dyno2 he's unknown and loses his
session.
So the logical solution would be to turn around to something like
Rack::Session::Memcache and plug it in with Heroku's Memcache/membase
addon in order to have a shared Memcache server to host the session
data across all Dynos.
Unfortunately it seems we cannot get Rack::Session::Memcache to play
well with Heroku because the standard Memcache client is not supported
by Heroku, and the client they recommend (Dalli) is not Rack level and
therefore can't be used in Rack::Session::Memcache.

Since I'm certainly not the first one to build a Sinatra app on Heroku
that requires shared session data across multiple dynos, I would like
to know how others have achieved this???
I'm sure a lot of us will learn from your answers.

(BTW, using just cookies is not an option as they are limited to 4K
and there is also data I don't want to send over. Thus the need for
just a session_id cookie with all stored server side)

Thanks!

-- 
You received this message because you are subscribed to the Google Groups 
"Heroku" group.
To post to this group, send email to heroku@googlegroups.com.
To unsubscribe from this group, send email to 
heroku+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/heroku?hl=en.

Reply via email to