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:[EMAIL PROTECTED] 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 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 <[EMAIL PROTECTED]> 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/