Re: php session memcache handler 3x more sets than gets
| From: | Stan | Date: | Tue, 04 Aug 2009 11:37:17 +0000 |
| Subject: | Re: php session memcache handler 3x more sets than gets | ||
| References: | 1 2 3 4 5 | Groups: | php.pecl.dev |
| Request: | Send a blank email to pecl-dev+get-6551@lists.php.net to get a copy of this message | ||
Hi,
Just to complete this issue, this is possible explanation
Problem is related only to memcached version 3.0.4
In this version session locking was introduced.
What is actually happening is:
1. session_start does one get and one set command to memcached. Get is obvious and set I assume is lock of the session record in memcached.
2. do anything with session, nothing happens
3. session commit or end of the script, 2 set commands. One is obvious again, storing session and second one I assume is unlocking of session record in memcached.
This results in 1 GET and 3 SETs to memcached every page load.
So strange memcached statistics when memcached session handler is used and PECL module 3.0.4 is used are possibly explained.
Stan
Stan wrote:
Hi Brian, I tracked this issue down and isolated the problem. Whenever I call session_id() funtion I get into memcache server statistics 1 get, 1 hit, but strangely 3 sets. I've done this on test script containing nothing but session_start(); and session_id(); You said that your memcache statistics look normal, could you please tell me which PHP version are you running? and maybe memcache and PECL memcache module if you don't mind. Thanks a lot Stan Stan wrote:Nope there are no indications of such attack. Still this is happening constantly.. after 3 day of Stan wrote:That was my only logical reason why this could ever happen but we are private dating site and users can't browse web unless logged in so there is no really point to just come to see something and then leave. But as I'm thinking about it there might be someone trying to brute-force user accounts. Doing many requests and after login fail they obviously delete cookie so every try comes as a new session. Will have to check that possibility out. So you don't think this could be bug or normal behaviour of memcached session handler? Stan Brian Moon wrote:New sessions. You appear to have a lot of those. Does your site have a high bounce rate? People hitting one page and then leaving? If so, they will have a set without a get. The session will not exist on page load, no cookie. So, no get is needed. But at the end of the page, the set is called. Brian. -------- http://brian.moonspot.net/ On 6/4/09 10:16 AM, Stan wrote:Hi, I hope this is a right place to post this question, I apologize if is not. We are testing out memcache as session handler on oneof our production server. We have got installed version 3.0.4 of PECL memcache package. Despite read and write data to memcahce server seems to be pretty much the same we get 3x more set command than get commands which seems a little weird. I would expect 1:1 get to set similar to write and read data amount ratio. Is there a logical explanation for this? Thanks a lot Stan here is memcached stats: [pid] => 12709 [uptime] => 98239 [time] => 1244029678 [version] => 1.2.6 [pointer_size] => 64 [rusage_user] => 359.122443 [rusage_system] => 533.937369 [curr_items] => 149742 [total_items] => 12530243 [bytes] => 412168840 [curr_connections] => 58 [total_connections] => 4983 [connection_structures] => 286 [cmd_get] => 5765795 [cmd_set] => 16948817 [get_hits] => 5683669 [get_misses] => 82126 [evictions] => 0 [bytes_read] => 50024940586 [bytes_written] => 50218604759 [limit_maxbytes] => 1073741824 [threads] => 4