Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33077 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 33138 invoked by uid 1010); 10 Nov 2007 11:39:49 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 33122 invoked from network); 10 Nov 2007 11:39:49 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Nov 2007 11:39:49 -0000 Authentication-Results: pb1.pair.com header.from=arend@hyves.nl; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=arend@hyves.nl; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain hyves.nl designates 217.170.2.100 as permitted sender) X-PHP-List-Original-Sender: arend@hyves.nl X-Host-Fingerprint: 217.170.2.100 mail1.exchange.cysonet.com Windows 2000 SP4, XP SP1 Received: from [217.170.2.100] ([217.170.2.100:31517] helo=mail1.exchange.cysonet.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BA/8F-24268-28895374 for ; Sat, 10 Nov 2007 06:39:48 -0500 Received: from hyves1.exchange.cysonet.com ([85.158.200.92]) by mail1.exchange.cysonet.com with Microsoft SMTPSVC(6.0.3790.3959); Sat, 10 Nov 2007 12:39:43 +0100 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C8238E.678970A9" Date: Sat, 10 Nov 2007 12:39:50 +0100 Message-ID: X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PHP-DEV] Making parallel database queries from PHP Thread-Index: AcgjhNElPVKTYwORTcqJEpukzKZoyAACMtg8 References: To: Cc: "Alexey Zakhlestin" X-OriginalArrivalTime: 10 Nov 2007 11:39:43.0802 (UTC) FILETIME=[634789A0:01C8238E] Subject: RE: [PHP-DEV] Making parallel database queries from PHP From: arend@hyves.nl ("Arend van Beelen") ------_=_NextPart_001_01C8238E.678970A9 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable While I can see the theoretical advantage of this, I wonder how much = there's too gain in practice (at least for us, that is). In our current codebase, when a database query is done, PHP can only = continue when it has the result anyway, so it would require serious code = modifications to make use of such functionality. Also, while it may = theoratically shorten page load times, our webservers are already = constraint by CPU load anyway, so we would probably not be able to get = more pageviews out of it either. -----Oorspronkelijk bericht----- Van: Alexey Zakhlestin [mailto:indeyets@gmail.com] Verzonden: za 10-11-2007 11:31 Aan: Arend van Beelen CC: internals@lists.php.net Onderwerp: Re: [PHP-DEV] Making parallel database queries from PHP =20 I would prefer to have some function, which would check, if the requested data is already available (if it is not, I would still be able to do something useful, while waiting) On 11/10/07, Arend van Beelen wrote: > Hi there, > > I am researching the possibility of developing a shared library which = can > perform database queries in parallel to multiple databases. One = important > requirement is that I will be able to use this functionality from PHP. > Because I know PHP is not thread-safe due to other libraries, I am = wondering > what would be the best way to implement this. Right now I can imagine = three > solutions: > > - Use multiple threads to connect to the databases, but let the = library > export a blocking single-threaded API. So, PHP calls a function in the > library, this function spawns new threads, which do the real work. = Meanwhile > the function waits for the threads to finish, and when all threads are = done > it returns the final result back to PHP. > - Use a single thread and asynchronous socket communication. So, PHP = calls > the library function and this function handles all connections within = the > same thread using asynchronous communication, and returns the result = to PHP > when all communication is completed. > - Use a daemon on the localhost. Make a connection from PHP to the = daemon, > the daemon handles all the connections to the databases and passes the > result back to the connection made from PHP. > > Can someone give me some advise about advantages of using one approach = or > another? Please keep in mind that I'm hoping for a solution which will = be > both stable and minimizes overhead. > > Thanks, > Arend. > > -- > Arend van Beelen jr. > "If you want my address, it's number one at the end of the bar." > --=20 Alexey Zakhlestin http://blog.milkfarmsoft.com/ ------_=_NextPart_001_01C8238E.678970A9--