1

We have a sinatra app which is running on passenger + nginx setup, Currently we are facing an issue that Session gets lost randomly. We also tried disabling smart spawning in passenger but it didn't worked.Server load and memory usage is also fine.

But we were able to fix the issue by setting passenger_max_pool_size 1;in nginx configuration.

Why this issue is happening when pool size is greater than 1 ?
Will this configuration cause any performance issue with our app since passenger cant spawn new instances ?

nginx sites-enabled conf

 server {
     listen 8082;
     server_name 0.0.0.0;
     root /home/deploy/manager/current/app/public;
     passenger_ruby /usr/local/rvm/gems/ree-1.8.7-2012.02/wrappers/ruby;
     passenger_enabled on;

}
Shyam Jos
  • 201
  • 1
  • 5
  • 9
  • 1
    What session store are you using? The default cookie sessions should work ok here, but if you are using `Rack::Session::Pool` then each process will have it’s own set of sessions, which will result in you losing sessions like you describe. – matt Nov 21 '17 at 03:51

1 Answers1

0

You'll want to make sure you specify a session secret, otherwise one will be auto generated every time the process starts, wiping out any existing sessions.

Eg:

use Rack::Session::Cookie, :key => 'rack.session', :path => '/', :secret => 'yoursessionsecretgoeshere'

edit: You aren't having the problem with a pool size of 1 because you only have one process running. If you restart that process you'll probably see the sessions drop if you don't have a secret set.