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

Optimize request-response time #15

Merged
merged 9 commits into from
Nov 18, 2022
Merged

Conversation

qsdstefan
Copy link
Contributor

@qsdstefan qsdstefan commented Nov 14, 2022

  1. Problem
  • For every client network request, Laravel used to make network request to Ably for getting server time .
  • This is due to a lack of laravel support to persist static variables across multiple requests.
  1. Solution
  • Server time diff is saved in local file cache.
  • So only on the first request, time is fetched and then reused for subsequent requests.
  1. Result
  • Reduced response time depending on latency to Ably servers.
  • In my case, it was reduced from 350ms to 150ms on page loads where Ably server time was cached.

Fixed #16

@qsdstefan qsdstefan added the enhancement New feature or improved functionality. label Nov 14, 2022
@qsdstefan qsdstefan self-assigned this Nov 14, 2022
@qsdstefan qsdstefan requested a review from sacOO7 November 15, 2022 04:37
Copy link
Collaborator

@sacOO7 sacOO7 left a comment

Choose a reason for hiding this comment

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

LGTM 👍

Copy link
Member

@owenpearson owenpearson left a comment

Choose a reason for hiding this comment

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

Any thoughts on why we need to disable some laravel/php combinations to make this work?

@sacOO7
Copy link
Collaborator

sacOO7 commented Nov 16, 2022

We are not actually disabling them. PHP 8.1 is already incompatible with laravel 6 and 7. Just that it was working for the time being. Laravel doesn't recommend using php 8.1 with laravel version 6 and 7

@sacOO7
Copy link
Collaborator

sacOO7 commented Nov 16, 2022

Any thoughts on why we need to disable some laravel/php combinations to make this work?

https://laravel.com/docs/8.x/releases#support-policy

You can see in the chart PHP 8.1 is not compatible with laravel 6 and 7

@owenpearson
Copy link
Member

@sacOO7 thanks for explaining 👍 @qsdstefan fwiw it would be good to have that kind of information in the PR/commit description in future

@qsdstefan
Copy link
Contributor Author

@sacOO7 thanks for explaining 👍 @qsdstefan fwiw it would be good to have that kind of information in the PR/commit description in future

Good thinking, I did not refer to the Laravel support policy when setting up the matrix for tests, which lead to the issue in the first place.

@owenpearson owenpearson merged commit 3758fd6 into main Nov 18, 2022
@owenpearson owenpearson deleted the feature/cache-server-time-diff branch November 18, 2022 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or improved functionality.
Development

Successfully merging this pull request may close these issues.

Optimize request-response time
3 participants