[wp-trac] [WordPress Trac] #41358: Shutdown hooks can significantly slow down REST API responses
WordPress Trac
noreply at wordpress.org
Thu Aug 10 06:53:31 UTC 2017
#41358: Shutdown hooks can significantly slow down REST API responses
-------------------------------------------------+-------------------------
Reporter: mikejolley | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting
Component: REST API | Review
Severity: normal | Version:
Keywords: has-patch dev-feedback needs- | Resolution:
testing | Focuses: rest-api,
| performance
-------------------------------------------------+-------------------------
Comment (by jnylen0):
I tested a few things locally:
- On nginx, `fastcgi_finish_request` is called; error logging during a
long `shutdown` hook seems to work fine, contrary to some of the above
reports (may depend on PHP version?)
- On apache, the logic to send `Connection: close` and other headers is
called, and works fine.
As noted at https://stackoverflow.com/a/27847878/106302, on both nginx and
apache, outputting after `finish_request` does nothing, '''unless'''
output is flushed (using `flush()` for example), in which case the script
will abort. This would be pretty terrible to debug, because the abort
doesn't appear to happen immediately.
Fortunately, as noted at https://bugs.php.net/bug.php?id=68772, this is
fixed for both webservers by calling `ignore_user_abort( true );` during
`finish_request`.
I also think we should change the Apache logic a bit: how do we know that
`ob_get_length()` is the correct content length? Maybe we can have
`serve_request` always send a `Content-Length` header based on the data it
echoes, and `finish_request` do the rest.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/41358#comment:4>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list