Session handling in Memcached?
Moderator: General Support Moderators
Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Windows Defender SmartScreen Issues <-- please read this if using Windows 10.
- fatica
- Joomla! Enthusiast
- Posts: 153
- Joined: Fri Jan 19, 2007 10:32 pm
- Contact:
Session handling in Memcached?
Hi all,
Is session handling in Memcached possible? Seems to be a lot of information regarding using memcached as a cache handler, but not for sessions.
Though, I see code in Joomla's session handling that manipulates jos_session regardless of the session handler setting.
This is posted in performance because Joomla spends a lot of time deleting and managing data in the jos_session table.
Thanks!
Is session handling in Memcached possible? Seems to be a lot of information regarding using memcached as a cache handler, but not for sessions.
Though, I see code in Joomla's session handling that manipulates jos_session regardless of the session handler setting.
This is posted in performance because Joomla spends a lot of time deleting and managing data in the jos_session table.
Thanks!
Mike Fatica
https://www.metalocator.com
https://www.metalocator.com
-
- Joomla! Virtuoso
- Posts: 4025
- Joined: Mon Nov 25, 2013 4:35 pm
- Location: Montreal, Canada
- Contact:
Re: Session handling in Memcached?
Commenting on your last statement:
If your website receives a lot of traffic, then it is extremely important to keep the session lifetime to a minimum - say 5-10 minutes. The downside for this is that administrators will be logged out after a few minutes of inactivity, but on the flip side, the session table will be substantially smaller and the website will be generally faster. We have discovered this the very hard way!
If your website receives a lot of traffic, then it is extremely important to keep the session lifetime to a minimum - say 5-10 minutes. The downside for this is that administrators will be logged out after a few minutes of inactivity, but on the flip side, the session table will be substantially smaller and the website will be generally faster. We have discovered this the very hard way!
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter
https://twitter.com/itoctopus - Follow us on Twitter
- fatica
- Joomla! Enthusiast
- Posts: 153
- Joined: Fri Jan 19, 2007 10:32 pm
- Contact:
Re: Session handling in Memcached?
Thanks for the comment.
Database session handling isn't really an option for us since our application requires a good, long session lifetime. Most users spend over an hour getting setting up in our application. The mysql-slow log is full of jos_session UPDATE and DELETE commands so we'd really like to get away from this method. Additionally the session table data adds significant overhead to mysql replication (we have 4 slave nodes that don't really need this day). I suppose it could be ignored in the repl configuration, but that sounds a little like the "tail wagging the dog".
I did discover these options with a little debugging and logins are working.
public $session_handler = 'memcached';
public $session_memcached_server_host = 'xxx.xxx.xxx.xxx';
There are, however, session functions within Joomla that work on jos_session regardless of the handler. That tells me that memcached is not supported fully for session handing. I can tell that with the above configuration session variables are stored within our memcached server correctly, though there are still queries hitting jos_session, so we'll need to investigate a little further.
Database session handling isn't really an option for us since our application requires a good, long session lifetime. Most users spend over an hour getting setting up in our application. The mysql-slow log is full of jos_session UPDATE and DELETE commands so we'd really like to get away from this method. Additionally the session table data adds significant overhead to mysql replication (we have 4 slave nodes that don't really need this day). I suppose it could be ignored in the repl configuration, but that sounds a little like the "tail wagging the dog".
I did discover these options with a little debugging and logins are working.
public $session_handler = 'memcached';
public $session_memcached_server_host = 'xxx.xxx.xxx.xxx';
There are, however, session functions within Joomla that work on jos_session regardless of the handler. That tells me that memcached is not supported fully for session handing. I can tell that with the above configuration session variables are stored within our memcached server correctly, though there are still queries hitting jos_session, so we'll need to investigate a little further.
Mike Fatica
https://www.metalocator.com
https://www.metalocator.com
- cbahiana
- Joomla! Enthusiast
- Posts: 186
- Joined: Wed Aug 24, 2005 2:03 pm
- Location: Rio de Janeiro
- Contact:
Re: Session handling in Memcached?
Hi itoctopus
I'm about to do a potentially very silly question, but bear with me:
So, setting "Session Lifetime" too high affects all user sessions? I thought that would only affect logged in users!
I'm about to do a potentially very silly question, but bear with me:
So, setting "Session Lifetime" too high affects all user sessions? I thought that would only affect logged in users!
Carlos Bahiana
You can't always get what you want, but if you try sometimes...
You can't always get what you want, but if you try sometimes...
-
- Joomla! Apprentice
- Posts: 10
- Joined: Sat Mar 23, 2013 1:31 pm
Re: Session handling in Memcached?
Based on what the user said, having a longer session time means that your 'database' is being written to more often and thus eats more resources. This statement related to the entire website's performance, as we are talking about the database as a whole being used more and consuming more resources as a whole. It doesnt matter what part of joomla is using the database more, if its using the database more, then overall performance potential goes down.cbahiana wrote:Hi itoctopus
I'm about to do a potentially very silly question, but bear with me:
So, setting "Session Lifetime" too high affects all user sessions? I thought that would only affect logged in users!
-
- Joomla! Virtuoso
- Posts: 4025
- Joined: Mon Nov 25, 2013 4:35 pm
- Location: Montreal, Canada
- Contact:
Re: Session handling in Memcached?
Let me explain as there seems to be a confusion about this particular issue. Every single visitor request will create an entry in the session table if not already created.
If you set the session lifetime to a high number than the session table will grow too large and then an insert/update query will take a very long time. In fact, many large Joomla websites are slow because for that particular reason.
If you think about it, what's the point of having a long lifetime for a session? The only reason we see our customers extending the session lifetime is to prevent administrators from logging out after many hours of inactivity.
There is a reason why the default session lifetime in Joomla is just 15 minutes, and not more.
If you set the session lifetime to a high number than the session table will grow too large and then an insert/update query will take a very long time. In fact, many large Joomla websites are slow because for that particular reason.
If you think about it, what's the point of having a long lifetime for a session? The only reason we see our customers extending the session lifetime is to prevent administrators from logging out after many hours of inactivity.
There is a reason why the default session lifetime in Joomla is just 15 minutes, and not more.
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter
https://twitter.com/itoctopus - Follow us on Twitter
- Per Yngve Berg
- Joomla! Master
- Posts: 30926
- Joined: Mon Oct 27, 2008 9:27 pm
- Location: Romerike, Norway
Re: Session handling in Memcached?
Have you tried changing the database engine from Innodb to Memory for the session table?
http://dev.mysql.com/doc/refman/5.6/en/ ... ngine.html
How many rows in the session table do we talk about?
http://dev.mysql.com/doc/refman/5.6/en/ ... ngine.html
How many rows in the session table do we talk about?
- Per Yngve Berg
- Joomla! Master
- Posts: 30926
- Joined: Mon Oct 27, 2008 9:27 pm
- Location: Romerike, Norway
Re: Session handling in Memcached?
PS. I had to change the data field to VARCHAR(4096) before changing table to Memory. Blob is not supported in Memory tables.
-
- Joomla! Virtuoso
- Posts: 4025
- Joined: Mon Nov 25, 2013 4:35 pm
- Location: Montreal, Canada
- Contact:
Re: Session handling in Memcached?
No - haven't used the memory table. Why doesn't Joomla use it by default? All MySQL instances can have tables of type "Memory".
We're talking about 200k+ rows.
We're talking about 200k+ rows.
http://www.itoctopus.com - Joomla consulting at its finest
https://twitter.com/itoctopus - Follow us on Twitter
https://twitter.com/itoctopus - Follow us on Twitter
- cbahiana
- Joomla! Enthusiast
- Posts: 186
- Joined: Wed Aug 24, 2005 2:03 pm
- Location: Rio de Janeiro
- Contact:
Re: Session handling in Memcached?
That's precisely my case. I have content editors that complain heavily on getting logged out too soon and too often, because they need to take calls and get interrupted during content production, so I raised the lifetime considerably. I had no concept that that was also changing public users session time!The only reason we see our customers extending the session lifetime is to prevent administrators from logging out after many hours of inactivity.
Carlos Bahiana
You can't always get what you want, but if you try sometimes...
You can't always get what you want, but if you try sometimes...