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

dev/core#1035 Add in new setting http_timeout to set how long in seco… #14525

Merged
merged 1 commit into from
Jun 15, 2019

Conversation

seamuslee001
Copy link
Contributor

@seamuslee001 seamuslee001 commented Jun 14, 2019

…nds should HTTP requests last for to fix dev/core#1035

Overview

CiviCRM performs system status checks when the CiviCRM menu route is executed. This can be on every page load. Some of the system status checks execute an internal HTTP request back to the CiviCRM site.
Some users (2 on Stack Exchange URL?) have reported that they are seeing incorrect CiviCRM status check alert failure messages in the CiviCRM UI. This is due to the default timeout being too low and not long enough for their CiviCRM site to complete the individual status check via HTTP.
This PR increases the default from 0.5 seconds to 5 seconds, with the view that this should be sufficient time for most CiviCRM sites to complete the check successfully and not trigger the alert message to the user.
It should be noted that prior to the 0.5 second timeout being introduced, there was no timeout at all and CiviCRM would wait indefinitely until the status check was completed.

From CiviCRM 5.15 onwards there is a hidden setting (http_timeout) for the HTTP request timeout in seconds. The default for this is 5 seconds. Adjusting the timeout will affect both the page load times (lower time, pages will load faster), too low a timeout and CiviCRM status checks may not complete in time resulting in users seeing an incorrect status alert check failed warning message.

Before

No setting and time out was half a second

After

Setting with default timeout of 5s

This adds a setting to allow administrators to set how long HTTP requests should last for, especially for status checks, I have put this against the RC as it is a recent issue / regression on status checks

ping @eileenmcnaughton @totten

@civibot
Copy link

civibot bot commented Jun 14, 2019

(Standard links)

@jusfreeman
Copy link
Contributor

Just pointing out that this change was due to the CiviCRM HTTP request blocking all other processes from executing. So a default of 5 seconds will re-introduce the problem which was trying to be solved.
Users don't wait 5 seconds and add to that when you have many HTTP requests, each of them waiting up to 5 seconds, then that's a non-trivial performance issue.

Suggestion, leave a 0.25s default and if it's a problem for some sites they can override it locally.

@seamuslee001
Copy link
Contributor Author

I checked with John Twyman in AUG and also had a bit of discussion on the AUG team and we figured 1 / 2 might be more closer to a decent timeout so have set it to be 1s. I tend to agree with Justin in that we have known this check to slow down systems and the shorter the better but we have also seen that 0.5s is too short for some sites and 1s seems to be relatively sensible timeout to me

@jusfreeman
Copy link
Contributor

@seamuslee001 thanks for taking on board.

What type of internal HTTP request cannot deliver a response in less than 1 second? Genuine question.

@eileenmcnaughton
Copy link
Contributor

@jusfreeman we've had 2 people report it happening to them - not ideal but... I'm happy to try 2 seconds but also I would imagine most partners would override the setting (potentially in civicrm.settings.php ) for their own sites - we have at least retained the ability to do that even if the default feels like an ugly compromise

'maxlength' => 3,
],
'default' => 1,
'add' => '5.16',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

5.15

*
* @return bool
*/
public function fileExists($url, $timeout = 0.50) {
public function fileExists($url, $timeout = FALSE) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we rename it to timeoutOverride?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@seamuslee001 see above - would that be clearer / more accurate?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eileenmcnaughton i don't think so i think its fine just as is

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 I'm generally OK with this - my reservations are whether we expose it through the UI initially - or it's just a documented advanced setting that partners etc might use. How about we don't set it through the UI in the rc / patch release variant and we pick that question up against core.

There are a couple of issues in setting it through the UI - mostly around clarity of information & risk of reduced stats ping backs that I feel deserve more leisurely consideration

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 discussed with @totten - can you remove from the form for now & leave at 5 seconds & also create a documentation ticket and / or PR & then we will merge

@seamuslee001
Copy link
Contributor Author

updated now @eileenmcnaughton

@seamuslee001
Copy link
Contributor Author

@eileenmcnaughton @totten documentation PR is here civicrm/civicrm-sysadmin-guide#170

@seamuslee001
Copy link
Contributor Author

Jenkins re test this please

'title' => ts('HTTP request timeout'),
'is_domain' => 1,
'is_contact' => 0,
'description' => ts('How long should HTTP requests through Guzzle application run for in seconds'),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit torn about mentioning guzzle here rather than being more generic - but it could iterate I guess

@jusfreeman
Copy link
Contributor

For those like me which are not sure why this PR was created, here is a bit more of a description based on Mattermost chat with Eileen.

Suggested amendment to the PR description
CiviCRM performs system status checks when the CiviCRM menu route is executed. This can be on every page load. Some of the system status checks execute an internal HTTP request back to the CiviCRM site.
Some users (2 on Stack Exchange URL?) have reported that they are seeing incorrect CiviCRM status check alert failure messages in the CiviCRM UI. This is due to the default timeout being too low and not long enough for their CiviCRM site to complete the individual status check via HTTP.
This PR increases the default from 0.25 seconds to 5 seconds, with the view that this should be sufficient time for most CiviCRM sites to complete the check successfully and not trigger the alert message to the user.
It should be noted that prior to the 0.25 second timeout being introduced, there was no timeout at all and CiviCRM would wait indefinitely until the status check was completed.

Have also suggested documentation change, civicrm/civicrm-sysadmin-guide#170 (comment)

@seamuslee001
Copy link
Contributor Author

thanks @jusfreeman updated i should also note that the previous timeout that was being passed was 0.5 as per the function definition not 0.25.

@jusfreeman
Copy link
Contributor

jusfreeman commented Jun 14, 2019

@seamuslee001 cool man and thanks. Correct 0.5s.

@eileenmcnaughton
Copy link
Contributor

@seamuslee001 I've given this merge on pass but I also have a non-blocking preference that you rename that variable name (per code comment)

…nds should HTTP requests last for to fix dev/core#1035

Handle situations where a 0 timeout is passed in

Remove from form

Update variable name as per EIleen
@seamuslee001 seamuslee001 merged commit 51da041 into civicrm:5.15 Jun 15, 2019
@seamuslee001 seamuslee001 deleted the feature_timeout_setting branch June 15, 2019 01:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants