Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:81884 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14592 invoked from network); 5 Feb 2015 09:06:00 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 5 Feb 2015 09:06:00 -0000 Authentication-Results: pb1.pair.com header.from=mike.php.net@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=mike.php.net@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.182 as permitted sender) X-PHP-List-Original-Sender: mike.php.net@gmail.com X-Host-Fingerprint: 74.125.82.182 mail-we0-f182.google.com Received: from [74.125.82.182] ([74.125.82.182:49420] helo=mail-we0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 27/6B-51979-77233D45 for ; Thu, 05 Feb 2015 04:05:59 -0500 Received: by mail-we0-f182.google.com with SMTP id l61so6369263wev.13 for ; Thu, 05 Feb 2015 01:05:56 -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=EEx87Pq3iUBiw3UxAdJKJB2d8Ucz+w6TJ7D2vbE9HLs=; b=P2ScLzon9rzbavQNJEk/uThpD2vjqmwSi03nbenUgH0urHT6e0smm04zDXj6JaERBJ jfD5zkKf9AEGD/fwuGRTRcz1jJC+ps5y+ZVLa7idNHh9XUc7XrVODyg98jjodzlYdydZ BsPd5YXsJHrZaTdoTzQg9QJU71kCpXvKp9bPJJrcabJoHQAF0JIK2irMHNrUbw8sMZ7z ANdPqbjhZkaKkykrY0lpRoBju91S1VDnXhgUVHfN6AlZT40bLB21RCnF5FOOVMyY5G+N kT2ukdJFTVT9MN7IJ96+w9SZVASbEzADz4bREPdf61efrRCXdwTpg1K3a+OxMU9pRV9c CwpQ== X-Received: by 10.180.77.39 with SMTP id p7mr53799372wiw.8.1423127156222; Thu, 05 Feb 2015 01:05:56 -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 hz9sm6393727wjb.17.2015.02.05.01.05.55 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 05 Feb 2015 01:05:55 -0800 (PST) Sender: Michael Wallner Message-ID: <54D33272.6050608@php.net> Date: Thu, 05 Feb 2015 10:05:54 +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> <54D32D89.7010509@php.net> <54D32FA7.8040807@gmail.com> In-Reply-To: <54D32FA7.8040807@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) On 05/02/15 09:53, Stanislav Malyshev wrote: > Hi! > >> Databases (see my pecl/pq example in the RFC), key/value stores, message >> queues, whatever you can think of. > > HTTP and databases are principally different. HTTP protocol is stateless > message-oriented protocol, and database connection protocols have very > little in common with HTTP. > >> To demonstrate to ou how it would work out over multiple requests. > > But this example doesn't demonstrate doing something that people > actually would or should do. And it also doesn't demonstrate a need for > persisting HTTP connections across requests. In fact, it may be harmful > for HTTP servers if connections were not closed when the user is done > with them but the server is forced to keep them open beyond the time > needed to serve the actual client. > >> 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. > > If the client is done with the connection, it is natural to assume it is > closed. If it's not, then client failing to finish the communication for > some reason may leave connection in wrong state and the other client may > unsuspectingly reuse it, leading to very weird results. > >>>> █ 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? :) > > Sorry, I looked at wrong number, there is a difference. But if you need > to talk a lot to the same service, why not just use keepalive connection > for all your requests? As I said, sharing connections between > unsuspecting clients may lead to problems. > Stas, we're talking in circles here :) Of course this is Keep-Alive. Keep in mind that it's curl which is working under the hood, managing alive connections for us. I just keep curl alive to take advantage of that fact. You can pass a persistent handle identifier (just a unique name) as second argument to the constructor of http\Client, so you can group related handles to max out that benefit. -- Regards, Mike