Archive for September, 2007

PHP’s curl_multi to the rescue

One of my Facebook apps hits Amazon’s Ecommerce Service (ECS) for item information via REST queries. I needed to process 19 separate queries searching for a title (basically searching 1 of 19 “browse nodes”), and return that data onto the Facebook canvas.

Simple enough, I could just do a foreach loop to make each REST request. Only problem was, say, each loop took 500 milliseconds total. That’s not hard when you consider all the steps: DNS, performing the REST query, waiting for the response, receiving the response, and then parsing the XML (in this case, using the SimpleXML extension). At 19 requests that’s 9.5 seconds which is way too slow, not to mention Facebook times out the request as well and returns a lovely error page.

For the test REST query I was benchmarking, it was averaging 9.65 seconds for the entire PHP script to complete (performing all 19 REST queries and then formatting the output). Simply switching from file_get_contents() to PHP’s cURL functions dropped the average to 7.32 seconds, a roughly 24% improvement. That was a great improvement, but still too slow and Facebook was still timing out the pages.

The root of the problem was that the 19 REST queries were sequential and as a result too slow. I needed to make those requests concurrently. Fortunately, PHP supported multi curl (basically making multiple cURL requests concurrently) via curl_multi_* functions.

BAM. Using curl_multi dropped the page generation time down to 1.6 seconds — much more reasonable and a 83.4% improvement. w00t.

INFJ

I’ve taken the Myers-Briggs several times since high school & I always appear to score the same (as they typically say you should). I just took one of those online tests again yesterday & yep, good ol’ INFJ.

I:

  • moderately expressed introvert
  • moderately expressed intuitive personality
  • moderately expressed feeling personality
  • moderately expressed judging personality

INFJ type description by D.Keirsey

INFJ type description by J. Butt and M.M. Heiss

Canon 24-70 f/2.8 vs Canon 24-105 f/4 IS

An oft asked question I hear is: if one is deciding on between the Canon 24-70 f/2.8 and the Canon 24-105 f/4 IS, which one is better?

Well, the answer is: it depends. For me personally ( I own both), I like to use the 24-105 when I travel on vacation and/or am shooting outdoors. I want to pack as light as reasonably possible when traveling, which means limiting the number of lenses I bring with me. I’ll always bring an ultra-wide (my 17-40 f/4) and then the remaining lens choice is between the 24-70 f/2.8, 24-105 f/4 IS, or 70-200 f/2.8 IS. The 24-105 is my choice since it’s in between the 24-70 & the 70-200 as well as being the lightest of the 3.

I’ve learned not to lug the 70-200 along with me unless I know I will specifically be shooting in a situtaion where I will need a long zoom. Years back I brought it with me on a trip to Paris as well as to Thailand — I didn’t use it once in either. I brought it with me to Playa del Carmen (near Cancun, Mexico) and Costa Rica, though, since I was planning on shooting wildlife.

When I shoot indoor events, I use the 24-70 f/2.8 since it is faster glass. Coupling Canon’s f/2.8 and faster lenses to a 1-series body (eg. my 1D MK II) activates more cross-type AF sensors which, if you’ve ever shot in low light, means that you’ll get faster focusing and less hunting. Nothing like waiting for your camera to lock focus in low light, especially when shooting fleeting moments of people.

24-105 Pros:

  • Image Stabilization
  • longer zoom end (105mm vs 70mm) — there are so many tims when I’ve used the 24-70 and said to myself, “if i only had just a little bit more reach”
  • lighter weight vs. the 24-70

24-105 Cons:

  • slower focusing in low light situations due to f/4 (at least on 1-series bodies – not sure if the non-”pro” bodies are the same way)
  • vignettes & barrel distorts at the wider focal lengths more than the 24-70, but you might not notice unless comparing side-by-side, though it can be automatically corrected in post-processing using something like the superb PTLens application
  • darker viewfinder image vs. the 24-70

24-70 Pros:

  • faster glass, which means better/faster focusing in low light
  • brighter viewfinder image

24-70 Cons:

  • on a 20d/30d/5d feels a bit lopsided due to it’s extra weight unless you have the optional battery grip.
  • heavy
  • no Image Stabilization

FTL: Logitech Control Center

My MacBook Pro kernel panics every once in a while which was mildly annoying (especially when uh I was in the middle of writing some code).

I couldn’t figure it out, but when my coworkers (2 of which have MBPs) said that they’ve never seen that happen, I began to think about what was different with my setup which might be causing the kernel panics & came to the conclusion that the Logitech Control Center control panel I have installed for my VX Revolution mouse was the likely culprit. A quick google seemed to confirm my suspicion; too bad it took me this long to figure out.

Flocking Logitech!