mysql - What method should be used for rails session storage? How to decide? -
what best method storing session data on rails? depends on needs key factors go decision , ideal session stores different scenarios?
security should concern. bear in mind stored on client side (such cookies, form post parameters, parameters, etc.) can modified using browser proxies. so, validate comes through browser. encrypt values in cookies or form post parameters wel. also, steve mentioned, cookies should used small values.
the default file based method if you're not going running on cluster of servers, or if are, if can tolerate users' sessions getting lost if server goes down (they have log in). vast majority of apps, acceptable. you'll need configure load balancer "sticky sessions", means given user bound single server. can make load balancing bit more difficult though, you'll find many users bound single server while server sits there idle.
if require shared session state across cluster, have couple of primary options. if traffic not extreme, , can deal short bit of latency, can store session information in database. long database up, session data won't lost. if database down, well, session data least of worries. if app has high traffic, or incredibly performance critical, best bet use distributed cache, such memcached. "infrastructure" you're going have maintain , monitor, however. if memcached distributed, it's still point of failure you're adding application's environment. so, don't take lightly if don't need it.
to make long story short, i'd default file based session storage approach acceptable 90+% of applications.
Comments
Post a Comment