Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33072 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 54846 invoked by uid 1010); 10 Nov 2007 01:31:13 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 54830 invoked from network); 10 Nov 2007 01:31:13 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Nov 2007 01:31:13 -0000 Received: from [127.0.0.1] ([127.0.0.1:17333]) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ECSTREAM id 26/F4-24268-0E905374 for ; Fri, 09 Nov 2007 20:31:12 -0500 Authentication-Results: pb1.pair.com header.from=arendjr@gmail.com; sender-id=pass; domainkeys=bad Authentication-Results: pb1.pair.com smtp.mail=arendjr@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.146.182 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: arendjr@gmail.com X-Host-Fingerprint: 209.85.146.182 wa-out-1112.google.com Received: from [209.85.146.182] ([209.85.146.182:59774] helo=wa-out-1112.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id BF/E4-24268-BE805374 for ; Fri, 09 Nov 2007 20:27:08 -0500 Received: by wa-out-1112.google.com with SMTP id l24so853574waf for ; Fri, 09 Nov 2007 17:27:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; bh=xUQCy6K9scqBuxW3c+rW4Lc8WV0WgY3/c8doaEppXTs=; b=bIgwxRwvRwJn5SC28An9yE57tOA7tIPoCjtG0JUgH8Q597yBfZcmuRczOZB9Zb16+DXEt+XsNxDRiNNXQ2M1nxnJRNRsE6yNLUzdpL6eYmGSj+/QAidn9O+KlHPl6oZ6ghOPs2/++OB7WBZXqN3FRBmWoEYyhLnjlfYpslAQCuM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:sender:to:subject:mime-version:content-type:x-google-sender-auth; b=cSerZf2/vwpsKuPiFjKSv14UYcZ5m3CuhIL7G/9SPs79qYZAF7q9FBQOILE/Q3C0paCs594296f/fzexW8vukW+uJj77Uqjy4BMjPQuDJhnvfkfO2gL7BHqxsmryTB8M+IMSvV2EXkeCErmjZOLTjgb/LSPQWl1zxS6TGGhIo9I= Received: by 10.115.59.4 with SMTP id m4mr1446169wak.1194658025139; Fri, 09 Nov 2007 17:27:05 -0800 (PST) Received: by 10.114.255.20 with HTTP; Fri, 9 Nov 2007 17:27:05 -0800 (PST) Message-ID: Date: Sat, 10 Nov 2007 02:27:05 +0100 Sender: arendjr@gmail.com To: internals@lists.php.net MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_19507_3359347.1194658025118" X-Google-Sender-Auth: 8a3e9b52914805d3 Subject: Making parallel database queries from PHP From: arend@hyves.nl ("Arend van Beelen") ------=_Part_19507_3359347.1194658025118 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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." ------=_Part_19507_3359347.1194658025118--