如果您在Heroku上运行一个带有多个Web dyno的Rails 3应用程序,
- 每次访问应用程序时,您通常会连接到不同的Web dyno吗?
- 会话是否可以在不同的Web dyno之间工作?
- 对于不同的Rails会话存储(ActionDispatch :: Session :: CookieStore, ActiveRecord :: SessionStore和ActionDispatch :: Session :: CacheStore),它是否有效?
如果您在Heroku上运行一个带有多个Web dyno的Rails 3应用程序,
ActionDispatch::Session::CacheStore Yes. The cache store stores session data in a cache, such as Memcached or Redis. This allows you to scale your application horizontally, as multiple web dynos can share the same cache instance.
是的。Cookie存储将加密的会话数据存储在数据库表中。然后会分配一个ID作为cookie。因此,您的浏览器会将ID发送到主机,然后使用它从数据库中加载会话数据。由于所有Web dynos都连接到数据库,因此这也是被支持的。