Bug #75471 [NEW]: PHP curl through proxy generating high CPU load

From: Date: Tue, 31 Oct 2017 22:37:16 +0000
Subject: Bug #75471 [NEW]: PHP curl through proxy generating high CPU load
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-212396@lists.php.net to get a copy of this message
From: alessandro dot ballini at gmail dot com Operating system: Ubuntu 16.04 PHP version: 7.0.25 Package: cURL related Bug Type: Bug Bug description:PHP curl through proxy generating high CPU load Description: ------------ After investigating the reasons for the high CPU load generated by an application sending many curl requests with 20 parallel PHP-cli scripts, I've found out the main reason is the PROXY option set to the curl handle. The following code is generating a 0.5-1.5% CPU load at the moment of curl_exec when run without the proxy and 12-25% when using any HTTP proxy (I've tried many different ones). It is NOT happening with a SOCK5 proxy type. With many threads running many requests at the same time, it soon becomes critical. I'm using: curl 7.55.1 (x86_64-conda_cos6-linux-gnu) libcurl/7.55.1 OpenSSL/1.0.2l zlib/1.2.11 libssh2/1.8.0 Release-Date: 2017-08-14 Protocols: dict file ftp ftps gopher http https imap imaps pop3 pop3s rtsp scp sftp smb smbs smtp smtps telnet tftp Features: AsynchDNS IPv6 Largefile NTLM NTLM_WB SSL libz TLS-SRP UnixSockets HTTPS-proxy Test script: --------------- do { $ch = curl_init(); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); curl_setopt($ch, CURLOPT_TIMEOUT, 10); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_ENCODING, 'identity'); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_PROXY, 'xxx'); curl_setopt($ch, CURLOPT_PROXYPORT, 'xxx'); curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); //curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_SOCKS5); curl_setopt($ch, CURLOPT_URL, 'https://api.ipify.org?format=json'); curl_exec($ch); curl_close($ch); sleep(10); } while (true); -- Edit bug report at https://bugs.php.net/bug.php?id=75471&edit=1 -- Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=75471&r=trysnapshot54 Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=75471&r=trysnapshot55 Try a snapshot (trunk): https://bugs.php.net/fix.php?id=75471&r=trysnapshottrunk Fixed in SVN: https://bugs.php.net/fix.php?id=75471&r=fixed Fixed in release: https://bugs.php.net/fix.php?id=75471&r=alreadyfixed Need backtrace: https://bugs.php.net/fix.php?id=75471&r=needtrace Need Reproduce Script: https://bugs.php.net/fix.php?id=75471&r=needscript Try newer version: https://bugs.php.net/fix.php?id=75471&r=oldversion Not developer issue: https://bugs.php.net/fix.php?id=75471&r=support Expected behavior: https://bugs.php.net/fix.php?id=75471&r=notwrong Not enough info: https://bugs.php.net/fix.php?id=75471&r=notenoughinfo Submitted twice: https://bugs.php.net/fix.php?id=75471&r=submittedtwice register_globals: https://bugs.php.net/fix.php?id=75471&r=globals PHP 4 support discontinued: https://bugs.php.net/fix.php?id=75471&r=php4 Daylight Savings: https://bugs.php.net/fix.php?id=75471&r=dst IIS Stability: https://bugs.php.net/fix.php?id=75471&r=isapi Install GNU Sed: https://bugs.php.net/fix.php?id=75471&r=gnused Floating point limitations: https://bugs.php.net/fix.php?id=75471&r=float No Zend Extensions: https://bugs.php.net/fix.php?id=75471&r=nozend MySQL Configuration Error: https://bugs.php.net/fix.php?id=75471&r=mysqlcfg

« previous php.bugs (#212396) next »