News Feed
Sections




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

Segment.io:
How to Make Async Requests in PHP
February 06, 2013 @ 09:52:49

On the Segment.io blog there's a new post by Calvin talking about making asyncronous requests in PHP and three different approaches you could use, depending on your situation.

When designing client libraries to send data to our API, one of our top priorities is to make sure that none of our code affects the performance of your core application. That is tricky when you have a single-threaded, "shared-nothing" language like PHP. [...] Ideally, we like to keep the setup process minimal and address a wide variety of use cases. As long as it runs with PHP (and possibly a common script or two), you should be ready to dive right in. We ended up experimenting with three main approaches to make requests in PHP. Here's what we learned.

Their three suggestions don't involve external dependencies (like a queue server) and can operate pretty quickly:

  • Opening a socket and closing it before waiting for a response
  • Write to a log file (a pseudo-queue)
  • Fork a curl process (through something like exec)

They each have small code examples included with them and explanations as to their plusses and minuses. For their needs, the "forked curl" solution worked out the best, but check out the other options too - you might have different needs.

0 comments voice your opinion now!
asynchronous request socket curl log queue tutorial


blog comments powered by Disqus

Similar Posts

NetTuts.com: Build Web Apps from Scratch with Laravel - The Eloquent ORM

Kristina Chodorow's Blog: Writing a PHP Extension (Four Part Series)

NetTuts.com: How to Write Testable and Maintainable Code in PHP

Abhinav Singh's Blog: Setting Nginx, PHP Fastcgi and XCache on a new Ubuntu

Community News: PHPKnowHow.com - PHP in Plain English


Community Events





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


opinion library laravel series interview symfony podcast api deployment framework bugfix community introduction release voicesoftheelephpant language package install tips list

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