News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Gonzalo Ayuso's Blog:
Speed up PHP scripts with asynchronous database queries
October 11, 2010 @ 11:49:53

In a new post to his blog Gonzalo Ayuso has a suggestion for speeding up your scripts that use multiple database connections, possibly ones with larger queries that could take a while to run - asynchronous query handling.

That's the situation. A web application with 4 heavy queries. Yes I know you can use a cache or things like that but imagine you must perform the four queries yes or yes. As I say before the four database queries are heavy ones. 2 seconds per one. Do it sequentially, that's means our script will use at least 8 seconds (without adding the extra PHP time). Eight seconds are a huge time in a page load. So here I will show up a technique to speed up our website using asynchronous calls.

Since PHP doesn't really support threading, he works around it by creating a separate script for each of the queries (obviously only practical for special cases) as a self-contained unit. Then the "master" script that needs the results of the queries calls each of them via asynchronous curl class (simply named "Fork") that sends off the requests and waits for each result to come back as a json result set.

1 comment voice your opinion now!
database asynchronous query curl json


blog comments powered by Disqus

Similar Posts

Juozas Kaziukenas' Blog: Scraping login requiring websites with cURL

Oracle Technology Network: Oracle Database 10g Express Edition and Zend Core for Oracle

DevArticles: Building an AJAX-Based Chat - Interacting With a Database

Brent Meshier's Blog: Blocking visitors by country using PHP & MySQL

PHPMaster.com: Database Interaction Made Easy with NotORM


Community Events





Don't see your event here?
Let us know!


release introduction opinion laravel series library version security symfony artisanfiles language conference list framework podcast community interview tool voicesoftheelephpant composer

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework