Why CodeIgniter's Curl library slower than using Curl in plain PHP? Why CodeIgniter's Curl library slower than using Curl in plain PHP? codeigniter codeigniter

Why CodeIgniter's Curl library slower than using Curl in plain PHP?


I'm not sure I know the exact answer for this, but I have a few observations about Curl & CI as I use it extensively.

  1. Check for the state of DNS caches/queries.

I noticed a substantial speedup when code was uploaded to a hosted staging server from my dev desktop. It was traced to a DNS issue that was solved by rebooting a bastion host... You can sometimes check this by using IP addresses instead of hostnames.

  1. Phil's 'library' is really just a wrapper.

All he's really done is map CI-style functions to the PHP Curl library. There's almost nothing else going on. I spent some time poking around (I forget why) and it was really unremarkable. That said, there may well be some general CI overhead - you might see what happens in another similar framework (Fuel, Kohana, Laravel, etc).

  1. Check your reverse lookup.

Some API's do reverse DNS checks as part of their security scanning. Sometimes hostnames or other headers are badly set in buried configs and can cause real headaches.

  1. Use Chrome's Postman extension to debug REST APIs.

No comment, it's brilliant - https://github.com/a85/POSTMan-Chrome-Extension/wiki and you have fine grained control of the 'conversation'.


I would have to know more about the CI Library and if it is doing any extra tasks on the gathered data but I would try naming your method to something other than the library name. I have had issues where with the Facebook library, calling it in a method named facebook caused problems. $this->curl could be ambiguous to if you are talking about the library or the method.

Also, try adding the debug profiler and see what it comes up with. Add this either in the construct or the method:

$this->output->enable_profiler(TRUE);