Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81875 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 525 invoked from network); 5 Feb 2015 08:45:02 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 08:45:02 -0000 Authentication-Results: pb1.pair.com smtp.mail=mike.php.net@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=mike.php.net@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.212.172 as permitted sender) X-PHP-List-Original-Sender: mike.php.net@gmail.com X-Host-Fingerprint: 209.85.212.172 mail-wi0-f172.google.com Received: from [209.85.212.172] ([209.85.212.172:39373] helo=mail-wi0-f172.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 4D/38-51979-D8D23D45 for ; Thu, 05 Feb 2015 03:45:02 -0500 Received: by mail-wi0-f172.google.com with SMTP id h11so37171425wiw.5 for ; Thu, 05 Feb 2015 00:44:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=Pcf0ouGc6KJ7QOvksdA0Nlc+M3CCC4stzBN1GTYLVS0=; b=F9Yh1Ow/94Y+ParOrUnQuIU8RtCwNVr7bBIsObZArFPKpQBLfWt8PFqBMdXUCrctRS R9Blkk2vGyDyI2o5wTImPDS7H/WwqziUnEyBV9Rx9t03gCfFBgjXl8ZK9mCbJ+DrldUR Jq2UmdsB6hx4unMDqmkN4PcQS58sBCtMbyQfje5nQ0ZO57KHWjHNUPPZyYiJpq8CwLJs kdzL0TXhtg/XXxhJbMTdvsL04xrFMAVZiW+lgoKEkV7UQx+aWAtzk6ZZ3HdF8CdylwQG eugn2LtssCZskR6VV9JT57gxGhQ1C/EEsS2zpP7DilddkbBeC4lmGJcWVuIvykZOQeHI 3KDQ== X-Received: by 10.194.94.1 with SMTP id cy1mr4860429wjb.127.1423125899446; Thu, 05 Feb 2015 00:44:59 -0800 (PST) Received: from [192.168.2.120] (89-104-28-113.customer.bnet.at. [89.104.28.113]) by mx.google.com with ESMTPSA id q10sm6285503wjr.41.2015.02.05.00.44.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 00:44:58 -0800 (PST) Sender: Michael Wallner Message-ID: <54D32D89.7010509@php.net> Date: Thu, 05 Feb 2015 09:44:57 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Stanislav Malyshev , PHP Internals References: <54D217E7.8030407@php.net> <54D2AE91.8090800@gmail.com> <54D3271E.2080207@php.net> <54D32A38.9050004@gmail.com> In-Reply-To: <54D32A38.9050004@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [PHP-DEV] Re: [RFC] [DISCUSSION] pecl_http From: mike@php.net (Michael Wallner) Hi Stas! On 05/02/15 09:30, Stanislav Malyshev wrote: > Hi! > >> think raphf is far more of practical use. Why should HTTP, or even more >> HTTPS or HTTP2, be any different than another service, especially when > > Which "another service"? Databases (see my pecl/pq example in the RFC), key/value stores, message queues, whatever you can think of. > >> HTTP APIs are so common nowadays. > > HTTP APIs are common, but almost none of them ever require persistent > connections. The nature of HTTP is a stateless protocol oriented for > short-lived connections (yes, I know there are exceptions, but they are > rare and mostly abuse HTTP rather than use it for intended purposes). All of that is true, but it's also true that HTTP has Keep-Alive which we should take advantage of if supported. Nothing else is happening here. >> With default of raphf.persistent_handle.limit=-1 (unlimited): >> █ mike@smugmug:~$ time php -r 'for ($i=0;$i<20;++$i) {(new >> http\Client("curl","google"))->enqueue(new http\Client\Request("GET", >> "http://www.google.at/"))->send();}' > > I'm not sure why you need persistence here - it's all happening within > one request - or why would you make 20 connections to the same service? To demonstrate to ou how it would work out over multiple requests. > If some service is used for multiple requests, it should implement > either batching or HTTP keepalive should be used, but simulating it > through keeping HTTP connection open when it is supposed to be closed by > the protocol sounds wrong. If you want to keep HTTP connection, why not > just have the client keep it? Why do you think the connection should automatically be closed? That's not the default case since HTTP/1.1, except the server is explicitely configured to close each connection after serving. > >> 0.03s user 0.01s system 2% cpu 1.530 total >> >> >> With raphf effectively disabled: >> █ mike@smugmug:~$ time php -d raphf.persistent_handle.limit=0 -r 'for >> ($i=0;$i<20;++$i) {(new http\Client("curl","google"))->enqueue(new >> http\Client\Request("GET", "http://www.google.at/"))->send();}' >> >> 0.04s user 0.01s system 1% cpu 2.790 total > > So, the difference is microscopic even here. But with proper HTTP > handling - like batch requests or keepalive - it would be even less. Microscopic?! 50%?! Could you please elaborate? :) -- Regards, Mike