Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:33074 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 23813 invoked by uid 1010); 10 Nov 2007 10:31:23 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 23796 invoked from network); 10 Nov 2007 10:31:22 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Nov 2007 10:31:22 -0000 Authentication-Results: pb1.pair.com smtp.mail=indeyets@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=indeyets@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 66.249.82.226 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: indeyets@gmail.com X-Host-Fingerprint: 66.249.82.226 wx-out-0506.google.com Received: from [66.249.82.226] ([66.249.82.226:14284] helo=wx-out-0506.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 32/0E-24268-97885374 for ; Sat, 10 Nov 2007 05:31:21 -0500 Received: by wx-out-0506.google.com with SMTP id s14so835890wxc for ; Sat, 10 Nov 2007 02:31:03 -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:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=bjnUQBBpsI0OVNXtcub/S8+k3hC0iIiKd24s2QxI228=; b=FsJ8W8F6rIBDRwaoESXNEsdVfC2hmmtUConNwb+Wt0x3iAW9rTJ9fLMZTLLwTuMu1A29kDOvHmkurd6632iKBFaNrqIJBNiNvFsVZVLFuxEQ7GKQydGEZADb+yjHfGOqLQ3bp1gxDFHazaw+HDB4+lGsvrsBDzbF11tCYaaEpIk= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:message-id:date:from:to:subject:cc:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=licrDQ6zOSlyrQbQ7tYrTSqFX5Ot1iIBfEgJoKo6LC0gDf82AF7KdaPekdu/+YFuarBLyS14LWLC+dzC2BFypBiBVNJlhahr82Sb7QoisdZ4Tp7AJwEvq4QmDyTlAHIfY4mGawydIokglB7ApalRHW2AfwUAmvFW7blciWKNgaU= Received: by 10.70.40.3 with SMTP id n3mr2725119wxn.1194690663458; Sat, 10 Nov 2007 02:31:03 -0800 (PST) Received: by 10.90.88.6 with HTTP; Sat, 10 Nov 2007 02:31:03 -0800 (PST) Message-ID: Date: Sat, 10 Nov 2007 13:31:03 +0300 To: "Arend van Beelen" Cc: internals@lists.php.net In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: Subject: Re: [PHP-DEV] Making parallel database queries from PHP From: indeyets@gmail.com ("Alexey Zakhlestin") 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." > -- Alexey Zakhlestin http://blog.milkfarmsoft.com/