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

Running too slow #68

Closed
ivent opened this issue Apr 9, 2017 · 3 comments
Closed

Running too slow #68

ivent opened this issue Apr 9, 2017 · 3 comments

Comments

@ivent
Copy link

ivent commented Apr 9, 2017

Hello, the script works very slow to 7 seconds to perform each operation, I know that the response of the firebase is fast so I wonder how it does to improve the response speed performance of the script.

@selimonline
Copy link

exact same issue. any ideas?

@ivent
Copy link
Author

ivent commented Jan 30, 2018

Hello, I have not made any improvements to my pho code but I still have a delay with regards to the library that needs to be solved. In javascript the updates are so fast that they seem to be instantaneous php should behave the same way or close to that rs

@mastef
Copy link

mastef commented Jun 18, 2019

@ivent @selimonline I had some very slow initial & consecutive requests ( 5-7 seconds per request ) and the changes below are how I resolved them. Also while debugging you can use curl_setopt($this->_ch, CURLOPT_VERBOSE, true); to see where it's hanging.

My getCurlHandler has the following added lines :

+        curl_setopt($this->_ch, CURLOPT_HTTPGET, true); // <-- to reset CURLOPT_POSTFIELDS
         curl_setopt($this->_ch, CURLOPT_URL, $url);
         curl_setopt($this->_ch, CURLOPT_TIMEOUT, $this->_timeout);
         curl_setopt($this->_ch, CURLOPT_CONNECTTIMEOUT, $this->_timeout);
+        curl_setopt($this->_ch, CURLOPT_SSL_VERIFYPEER, false); // <-- set to false to speed up SSL connections ; do at your own risk
         curl_setopt($this->_ch, CURLOPT_FOLLOWLOCATION, true); 
         curl_setopt($this->_ch, CURLOPT_RETURNTRANSFER, true);
+        // curl_setopt($this->_ch, CURLOPT_VERBOSE, true); // <-- for debugging, turn off after you're done
         curl_setopt($this->_ch, CURLOPT_CUSTOMREQUEST, $mode);
+        curl_setopt($this->_ch, CURLOPT_HTTPHEADER, []); // <-- reset headers when switching from write to read
+        curl_setopt($this->_ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); // <-- force ipv4, helps with servers that have ipv6 dns lookups misconfigured

@ktamas77 you might want to consider some of these. I think it's mainly the ipv6 lookups on servers that don't support ipv6 that are slowing down Curl; as it tries to look up the host with ipv6 and then falls back on ipv4 after it fails. Might want to have an option for this, similar to the SSL option in a recent version. Related SO : https://stackoverflow.com/a/26568867/10728554

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

No branches or pull requests

4 participants