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

Round out polling timestamp #496

Merged
merged 3 commits into from
Sep 16, 2018
Merged

Conversation

mjangda
Copy link
Member

@mjangda mjangda commented Jul 10, 2018

Rather than a random scatter of timestamps, we can get a much higher cache hit-rate by forcing/normalizing multiple clients to make a request with the same timestamp.

joshbetz
joshbetz previously approved these changes Jul 11, 2018
Rather than a random scatter of timestamps, we can get a much higher cache hit-rate by forcing/normalizing multiple clients to make a request with the same timestamp.
@mjangda
Copy link
Member Author

mjangda commented Jul 13, 2018

Lint issues have been fixed.

paulschreiber added a commit to paulschreiber/liveblog that referenced this pull request Aug 8, 2018
@philipjohn philipjohn added this to the 1.9 milestone Aug 8, 2018
@paulschreiber
Copy link
Contributor

Per @rogertheriault, this can result in timestamps in the future. Change Math.round() to Math.floor().

@philipjohn
Copy link
Contributor

I made @paulschreiber / @rogertheriault's suggested change and then ran a test. I took a simple Liveblog, opened it on 3 different clients (using different IPs) and proceeded to add new entries. I then looked at the API requests that came in from those clients.

What I saw was multiple clients using the same URLs, with clear 10-second intervals and the start time updating only occassionally. I have listed these request URLs below with readable start and end times.

# Request URL Start End
1 /wp-json/liveblog/v1/9/entries/1536402970/1536403670/ 10:36:10 10:47:50
2 /wp-json/liveblog/v1/9/entries/1536402970/1536403680/ 10:36:10 10:48:00
3 /wp-json/liveblog/v1/9/entries/1536402970/1536403690/ 10:36:10 10:48:10
4 /wp-json/liveblog/v1/9/entries/1536402970/1536403700/ 10:36:10 10:48:20
5 /wp-json/liveblog/v1/9/entries/1536403697/1536403710/ 10:48:17 10:48:30
6 /wp-json/liveblog/v1/9/entries/1536403697/1536403720/ 10:48:17 10:48:40
7 /wp-json/liveblog/v1/9/entries/1536403697/1536403730/ 10:48:17 10:48:50
8 /wp-json/liveblog/v1/9/entries/1536403697/1536403740/ 10:48:17 10:49:00
9 /wp-json/liveblog/v1/9/entries/1536403697/1536403750/ 10:48:17 10:49:10

As is clear, after request no. 4 the start time changes.

After the test, I used wp shell to run WPCOM_Liveblog::get_entries_by_time(1536402970,1536403700); which showed me the response data for request 4. In the data, the latest_timestamp property was set to 1536403696. This is clearly helping to set the new start time for subsequent requests.

Looks like, with the floor() change this PR resolves #489 nicely.

@rogertheriault
Copy link

We've (@mjangda actually) noticed that + config.timeDifference; can sometimes add a few minutes to the timestamp, if the page was cached. So that may be part of the problem when there's an active cache - it doesn't show up too well when just testing the individual requests. It might be necessary to drop that bit. Even without it, we've seen cases where there were still some future timestamps...

@paulschreiber
Copy link
Contributor

I was told to remove + config.timeDifference and did in my copy. Let's do that here, too.

@philipjohn
Copy link
Contributor

I've pushed the removal of the + config.timeDifference which looks good. I'm going to go ahead and merge seeing as we all seem to be on the same page on this.

@philipjohn philipjohn merged commit 44911f2 into master Sep 16, 2018
@GaryJones GaryJones deleted the update/normalize-polling-timestamp branch June 7, 2024 12:13
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.

5 participants