Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change session_lock default ini values #350

Merged
merged 2 commits into from
Jul 20, 2018
Merged

Change session_lock default ini values #350

merged 2 commits into from
Jul 20, 2018

Conversation

tvlooy
Copy link
Contributor

@tvlooy tvlooy commented Jun 1, 2017

The old extension had these values as a default. I don't know why this changed, the commit messages don't explain it. People are having issues with it #269 changing the values seems to help.

The max_retries was calculated but defaulted to max_execution_time when it was 0. I chose 30s as the default max_execution_time because this is the default in PHP.

ping @mkoppanen

@sodabrew
Copy link
Contributor

sodabrew commented Jun 2, 2017

I'd like to do some detective work to understand why the defaults were changed for 3.0 and if it makes sense to change them back. Thank you for taking the discussion in #269 and suggesting specific changes to address the problem reported there.

@tvlooy
Copy link
Contributor Author

tvlooy commented Jun 13, 2017

Note that we are running a high traffic (~140 cmd/s) site in production with these settings (we use both sessions and user cache) without any issues so far. We use PHP 7.1.

@jaccoTopVintage
Copy link

jaccoTopVintage commented Jun 13, 2017

It would be most interesting to learn the rationale behind changing the default values, as it seems it is the source of quite some problems.

From what I can see, the original values (4bb264e) where:

; Session spin lock retry wait time in microseconds.
; Be carefull when setting this value.
; Valid values are integers, where 0 is interpreted as
; the default value. Negative values result in a reduces
; locking to a try lock.
; the default is 150000
memcached.sess_lock_wait = 150000

; The maximum time, in seconds, to wait for a session lock
; before timing out.
; Setting to 0 results in default behavior, which is to
; use max_execution_time.
memcached.sess_lock_max_wait = 0;

; The time, in seconds, before a lock should release itself.
; Setting to 0 results in the default behaviour, which is to
; use the memcached.sess_lock_max_wait setting. If that is
; also 0, max_execution_time will be used.
memcached.sess_lock_expire = 0;

@sodabrew
Copy link
Contributor

Thanks for taking the time to present a new set of default values that may work better for most people. I will accept this PR, but I merged a cleanup PR ahead of this one that comments-out any default INI values that were explicitly set to the default values. Could you update this PR to reflect the new default values, but retain the commented-out status of the INI directives?

@sodabrew sodabrew added this to the 3.0.4 milestone Jun 13, 2017
@tvlooy
Copy link
Contributor Author

tvlooy commented Jun 13, 2017

@sodabrew I updated the PR

But, ... I also think we can improve the code even more. I'll make a new PR for:

Suggestion 1 (my preference): because nobody knows why the exponential backoff was added, I suggest we remove it and restore the original behavior.

Suggestion 2: change the default value of memcached.sess_lock_retries to -1, which will then take the value of max_execution_time to calculate the actual retries. Which leaves the exponential backoff stuff in for people that want to use it.

My guess is that nobody uses it. So removing it seems the best solution. We can always add it again later when it becomes clear why it was added.

What do you think?

@sodabrew
Copy link
Contributor

Regarding the exponential backoff, that type of algorithm is generally only useful if it is random exponential backoff, so that two requests that begin at exactly the same time will de-conflict after a few tries.

@tvlooy
Copy link
Contributor Author

tvlooy commented Jun 24, 2017

@sodabrew so, what's next?

@jaccoTopVintage
Copy link

@sodabrew I think the best course of action would be to revert revert back to the old retry algorithm (#355). If reverting to the old retry algorithm takes too much time to make it into the next release, I would suggest reverting back to the 'old' default values (this pull request) as an intermediate quickix.

@tvlooy
Copy link
Contributor Author

tvlooy commented Jul 31, 2017

@sodabrew did you find the time to take a look at this and #355 yet? I'm eager to make this extension better

@tvlooy
Copy link
Contributor Author

tvlooy commented Aug 30, 2017

Summoning the github php-memcached-dev people @andreiz @dterei @iliaal @krakjoe @mkoppanen @poison @tricky Anyone?

@sodabrew
Copy link
Contributor

Hi @tvlooy I've been waylaid on this project by other work I have going on right now, but I haven't forgotten and will make every effort to merge together the sensible defaults that have been proposed in PR and to cut a release.

@lichunqiang
Copy link

lichunqiang commented Oct 12, 2017

Hi all, I had tried this configure for the version 3.0.3, But casued anthor issue, the php slow log tracked session_start function, It's this configuration casued the function slow?

Or it can the server's response? I used a test server, maybe the configuration is too small to handle the frequent request?

libmemcached version 1.0.18

memcached configuration:

memcached support => enabled
memcached.compression_factor => 1.3 => 1.3
memcached.compression_threshold => 2000 => 2000
memcached.compression_type => fastlz => fastlz
memcached.default_binary_protocol => 0 => 0
memcached.default_connect_timeout => 0 => 0
memcached.default_consistent_hash => 0 => 0
memcached.serializer => php => php
memcached.sess_binary_protocol => 1 => 1
memcached.sess_connect_timeout => 0 => 0
memcached.sess_consistent_hash => 1 => 1
memcached.sess_lock_expire => 30 => 30
memcached.sess_lock_max_wait => not set => not set
memcached.sess_lock_retries => 200 => 200
memcached.sess_lock_wait => not set => not set
memcached.sess_lock_wait_max => 150 => 150
memcached.sess_lock_wait_min => 150 => 150
memcached.sess_locking => 1 => 1
memcached.sess_number_of_replicas => 0 => 0
memcached.sess_persistent => 0 => 0
memcached.sess_prefix => memc.sess. => memc.sess.
memcached.sess_randomize_replica_read => 0 => 0
memcached.sess_remove_failed_servers => 0 => 0
memcached.sess_sasl_password => no value => no value
memcached.sess_sasl_username => no value => no value
memcached.sess_server_failure_limit => 0 => 0
memcached.store_retry_count => 2 => 2

update

After full tests for our whole application, there also accoured session_start(): Unable to clear session lock record occasionally

@sodabrew sodabrew modified the milestones: 3.0.4, 3.0.5, 3.1.0 Nov 20, 2017
@lukaszklis
Copy link

lukaszklis commented Apr 10, 2018

@sodabrew is this PR critical enough to block a release of 3.1.0 (given no updates since November '17 and being carried over for the three milestones already)?

@tvlooy
Copy link
Contributor Author

tvlooy commented May 29, 2018

I am still running fine with these settings by the way. This issue is open near to a year now. You lost me ... sorry

@sodabrew sodabrew merged commit 549e7c8 into php-memcached-dev:master Jul 20, 2018
@sodabrew
Copy link
Contributor

sodabrew commented Jul 20, 2018

Sold. Will cut a release soon's I can.

@michaelbutler
Copy link

Is the comment about sess_lock_wait_min being milliseconds (and not microseconds) correct?

@woolardfa
Copy link

@michaelbutler yes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants