Open CodeZeno opened 5 years ago
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.
@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.
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?