[wp-trac] [WordPress Trac] #18738: Improving cron spawning and other non-blocking HTTP requests

WordPress Trac wp-trac at lists.automattic.com
Sat Sep 24 05:38:11 UTC 2011


#18738: Improving cron spawning and other non-blocking HTTP requests
-------------------------+------------------------------
 Reporter:  johnbillion  |       Owner:
     Type:  enhancement  |      Status:  new
 Priority:  normal       |   Milestone:  Awaiting Review
Component:  HTTP         |     Version:
 Severity:  normal       |  Resolution:
 Keywords:  has-patch    |
-------------------------+------------------------------

Comment (by dd32):

 Running the benchmarks against the 5second sleep script above:
 {{{
 Using curl
 6.569
 5.703

 Using fsockopen
 5.753
 0.344

 Using streams
 6.068
 6.105
 }}}

 I see similar speed issues against local resources (ie. google.com.au
 returns in 1.5seconds usually, except for fsockopen with a non-blocking
 request which does it in 0.08 seconds).

 Looking at the stream_set_blocking() function, it only operates on
 _socket_ and _local file_ resources, HTTP resources can't use non-blocking
 mode by itself. Streams would need to use stream_socket_create(
 'tcp://...') or 'ssl://...' and send HTTP headers manually in order to be
 able to use non-blocking requests (Effectively turning it into a Sockets
 class rather than a "streams" class). This would explain why 0.01s
 timeouts for cron doesn't work for some users, as the connection needs to
 be made, which often takes longer.

 Looking at curl, It supports Asynchronous requests through cURL's
 multi_exec functionality:  curl_multi_init() - however, it appears that
 you still need to call curl_multi_exec() in a loop to ensure that the
 request actually takes place "in the background".

-- 
Ticket URL: <http://core.trac.wordpress.org/ticket/18738#comment:3>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software


More information about the wp-trac mailing list