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

Considerable time added for TTFB #74

Open
CodeZeno opened this issue Jun 12, 2019 · 2 comments
Open

Considerable time added for TTFB #74

CodeZeno opened this issue Jun 12, 2019 · 2 comments
Labels

Comments

@CodeZeno
Copy link

What is the expected latency increase from using this library?

I have TTFB (Time To First Byte) times of around 30ms without and around 140ms with this library.
Is this expected for this library and are there ways to improve this performance?

@jorgeborges
Copy link
Contributor

jorgeborges commented May 31, 2020

The library makes a blocking HTTPS call to the Google Analytics server, adding around 100ms~200ms to any process that is executing it. If you are using it as part of a request that renders a web page, I would assume it would cause a bit hit on performance

When I wrote this library a few years ago it was with the intention of using it in background processes (such as a queue consumer), so the concept of TTFB was not a concern there.

As for ways to improve the performance, not sure. I don't develop on PHP too much nowadays, but I'm open to suggestions.

@linaspasv
Copy link

@CodeZeno if you are using php-fpm, you can use fastcgi_finish_request(); to return 200 HTTP response back to the browser asap. This way you are not blocking the request and the rest of the code can finish in the background.

The better approach would be to have a background process (queue) as suggested above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Development

No branches or pull requests

3 participants