-
Notifications
You must be signed in to change notification settings - Fork 795
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
Sync: Add Async Sender #7482
Sync: Add Async Sender #7482
Conversation
@lezama Do we still want to take this approach? |
what do you think about offering it as an alternative? |
Sure should we put in as an option or a constant? |
👍 |
This PR has been marked as stale. This happened because:
No further action is needed. But it's worth checking if this PR has clear testing instructions, is it up to date with master, and it is still valid. Feel free to close this issue if you think it's not valid anymore — if you do, please add a brief explanation. |
c794b98
to
f64c350
Compare
This is automated check which relies on |
This works as expected for me. To test this. I did the following.
Did an api call to the site. And then enabled the And notice that the error log still showed an do SYNC call. |
Based on the commit to core https://core.trac.wordpress.org/changeset/44488 That improves cron response. This PR tries to do the same but for Jetpack. This works together with #7482 To improve the page load response time when sync is progress.
@lezama can you review this again. |
sync/class.jetpack-sync-sender.php
Outdated
if ( $this->is_locked() ) { | ||
$self = $this->get_instance(); | ||
// Remove any sync sending... | ||
remove_action( 'shutdown', array( $self ,'do_sync' ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we use $this
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure maybe.
Based on the commit to core https://core.trac.wordpress.org/changeset/44488 That improves cron response. This PR tries to do the same but for Jetpack. This works together with #7482 To improve the page load response time when sync is progress. #### Testing instructions: * Go to '..' On an environment that support the function add the following to your code. ``` diff --git a/sync/class.jetpack-sync-sender.php b/sync/class.jetpack-sync-sender.php index 70cb4a09c..cd65e62bd 100644 --- a/sync/class.jetpack-sync-sender.php +++ b/sync/class.jetpack-sync-sender.php @@ -205,6 +205,8 @@ class Jetpack_Sync_Sender { if ( function_exists( 'fastcgi_finish_request' ) && version_compare( phpversion(), '7.0.16', '>=' ) ) { fastcgi_finish_request(); } + error_log( 'Does this show up' )? + sleep(10); $checkout_start_time = microtime( true ); ``` Do something that should trigger a sync request. Such as triggering a full sync or doing updating a setting. Next try doing an api request to you site. Without the call to fastcgi_finish_request(); the api request should take at least 10 seconds to complete. With the call to `fastcgi_finish_request();` the request should be a lot faster. #### Proposed changelog entry for your changes: * Improves sync performance on PHP 7.0.16 and higher with fastcgi_finish_request enabled.
testing.php
|
Is this ready for review? |
bb6c2b7
to
f64c350
Compare
Just checking on the expected timeline for this? Are we hoping to land it soon or could close if we're not going to add it? |
@enejb what do you think about this one? |
came up with a snippet we can use inside a plugin:
|
Thanks Kraft, agreed this can be closed and we are referencing it from Asana in the backlog for when we circle back to it. |
Add the option to load the Jetpack Sync Sender on another request as core does it for cron*. (hat tip @westi).
This feature is Off by default, and can be turned on via a
jetpack_sync_settings_async_sender
filter*We are avoiding just using
spawn_cron
as we already tried using it in the past, causing troubles with misconfigured cron setups.How to test
turn on the feature(off by default):
Use the sync settings endpoint to set
async_sender
to1
or
Using a filter:
add_filter('jetpack_sync_settings_async_sender', '__return_true');
on the ngrok console you should see a separate request to admin-ajax.php just for syncing
alternatively follow @enejb's instructions on Sync: add fastcgi finish request to sync #11146 and check that the original request doesn't get delayed