Session Management with memcached in Dancer1
Hello All, I am trying to learn session management in Dancer. I have consulted Dancer::Session documentation for the same. The document recommends to use memcached server for production and YAML or Simple for development. My question is specifically related to memcached server. Do I need to setup the memcached server on the system before using Dancer::Session::Memcached? Also, what does this "/var/sock/memcached" mean in the Dancer::Session::Memcached documentation (I believe it is the default location of memcached server after installation on local system)? I am sorry if my question is to silly. But I am trying to understand the right procedure. Thanks for the help. Best, Tushar Dave
Hi, I’ve been using Dancer::Session::Cookie but not in production yet. You don’t have to setup a “session server” with this approach.
On Apr 15, 2015, at 10:33 AM, Tushar Dave <tushardave26@gmail.com> wrote:
Hello All,
I am trying to learn session management in Dancer. I have consulted Dancer::Session documentation for the same. The document recommends to use memcached server for production and YAML or Simple for development. My question is specifically related to memcached server. Do I need to setup the memcached server on the system before using Dancer::Session::Memcached? Also, what does this "/var/sock/memcached" mean in the Dancer::Session::Memcached documentation (I believe it is the default location of memcached server after installation on local system)?
I am sorry if my question is to silly. But I am trying to understand the right procedure.
Thanks for the help.
Best, Tushar Dave
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
<http://www.bottlenose-wine.com/> Bill Carr, President at Bottlenose (413) 584-0400 http://www.bottlenose-wine.com <http://www.bottlenose-wine.com/> Download vCard <http://www.bottlenose-wine.com/vcard/BillCarr.vcf>
Bill, Once a website with cookies is in production it needs caching systems like Memcached or Redis for key-value data storage where you can access the data from different processes. In development one usually only runs a single process, but in production you'll normally want several processes to be running so that you can have lots of users visiting your site simultaneously. If you don't have a separate caching system then when user gets a cookie (e.g. logs in) with Process A then clicks on a link and that request winds up with Process B, it won't have access to the session data stored in Process A, and will think that the user's cookie is invalid. Tushar You're right that you need to install the memcached server for Dancer::Session::Memcached to work. The config line you're referring to memcached_servers: "10.0.1.31:11211,10.0.1.32:11211,10.0.1.33:11211 ,/var/sock/memcached" is just an example of how you communicate to Dancer how you've setup memcached. In this case you're saying - I've got a memcached daemon setup on boxes with IP addresses 10.0.1.31-33 all accessible on port 11211, and it's also running on the localhost and you should access it by writing to the socket /var/sock/memcached. For an explanation of memcached with multiple servers, read the answer starting with 'when you set several servers...' http://stackoverflow.com/questions/352536/how-to-link-memcached-server-toget... To see what I mean by 'socket' in reference to "/var/sock/memcached" see the 'Socket' section here: http://en.wikipedia.org/wiki/Unix_file_types I think the default of memcached_servers is 127.0.0.1:11211 (i.e localhost). That is, if you've got a single box in production with multiple processes and one memcached on the same box, you don't need a memcached_servers entry in the Dancer config file. [Experts, please correct me if I'm wrong since I've only done this with Dancer2] I hope that clears things up, and if not please say so! Andrew On Wed, Apr 15, 2015 at 4:01 PM, William Carr <bill@bottlenose-wine.com> wrote:
Hi,
I’ve been using Dancer::Session::Cookie but not in production yet. You don’t have to setup a “session server” with this approach.
On Apr 15, 2015, at 10:33 AM, Tushar Dave <tushardave26@gmail.com> wrote:
Hello All,
I am trying to learn session management in Dancer. I have consulted Dancer::Session documentation for the same. The document recommends to use memcached server for production and YAML or Simple for development. My question is specifically related to memcached server. Do I need to setup the memcached server on the system before using Dancer::Session::Memcached? Also, what does this "/var/sock/memcached" mean in the Dancer::Session::Memcached documentation (I believe it is the default location of memcached server after installation on local system)?
I am sorry if my question is to silly. But I am trying to understand the right procedure.
Thanks for the help.
Best, Tushar Dave
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
<http://www.bottlenose-wine.com/> Bill Carr, President at Bottlenose (413) 584-0400 http://www.bottlenose-wine.com Download vCard <http://www.bottlenose-wine.com/vcard/BillCarr.vcf>
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- Andrew Solomon Mentor@Geekuni http://geekuni.com/ http://www.linkedin.com/in/asolomon
On Wed, Apr 15, 2015 at 3:16 PM, Andrew Solomon <andrew@geekuni.com> wrote:
Bill,
Once a website with cookies is in production it needs caching systems like Memcached or Redis for key-value data storage where you can access the data from different processes.
Dancer::Session::Cookie doesn't use a backend at all; the session data is entirely stored in the (encrypted, signed) cookie. There are obvious downsides to this, but not the ones you mention.
If you have multiple instances running or your app is behind a load balancer on different hosts then you really need a caching system. If you use only one instance then the cookie is fine. On Thu, Apr 16, 2015 at 7:32 AM, Yitzchak Scott-Thoennes <sthoenna@gmail.com
wrote:
On Wed, Apr 15, 2015 at 3:16 PM, Andrew Solomon <andrew@geekuni.com> wrote:
Bill,
Once a website with cookies is in production it needs caching systems like Memcached or Redis for key-value data storage where you can access the data from different processes.
Dancer::Session::Cookie doesn't use a backend at all; the session data is entirely stored in the (encrypted, signed) cookie. There are obvious downsides to this, but not the ones you mention.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
On Wed, Apr 15, 2015 at 10:35 PM, Attila Bárdi <attila.bardi@gmail.com> wrote:
If you have multiple instances running or your app is behind a load balancer on different hosts then you really need a caching system. If you use only one instance then the cookie is fine.
That is exactly the opposite of what I said.
On 04/16/2015 07:35 AM, Attila Bárdi wrote:
If you have multiple instances running or your app is behind a load balancer on different hosts then you really need a caching system. If you use only one instance then the cookie is fine.
Well, the browser of the user will pass the cookie to the instance so you actually don't need to cache it on your server. That is the beauty of the cookie approach. Regards Racke
On Thu, Apr 16, 2015 at 7:32 AM, Yitzchak Scott-Thoennes <sthoenna@gmail.com <mailto:sthoenna@gmail.com>> wrote:
On Wed, Apr 15, 2015 at 3:16 PM, Andrew Solomon <andrew@geekuni.com <mailto:andrew@geekuni.com>> wrote:
Bill,
Once a website with cookies is in production it needs caching systems like Memcached or Redis for key-value data storage where you can access the data from different processes.
Dancer::Session::Cookie doesn't use a backend at all; the session data is entirely stored in the (encrypted, signed) cookie. There are obvious downsides to this, but not the ones you mention.
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm <mailto:dancer-users@dancer.pm> http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
_______________________________________________ dancer-users mailing list dancer-users@dancer.pm http://lists.preshweb.co.uk/mailman/listinfo/dancer-users
-- Modern Perl, Dancer and eCommerce consulting.
participants (6)
-
Andrew Solomon -
Attila Bárdi -
Stefan Hornburg (Racke) -
Tushar Dave -
William Carr -
Yitzchak Scott-Thoennes