Norm’s blog

Blabble here, blabble there.

Archive for the ‘Facebook’ Category

It’s interesting watching the growth of Describe Me. When a user first adds the app, he or she is automatically tagged by one of the developers as “cool,” in order to illustrate how the app works.

Recently I became the person tagging new users, and therefore get a ton of friend requests, pokes, or just “who the hell are you” emails from random people. At first it was just mainly people in the U.S., but I started to get requests and pokes from South Africa, Sweden, Hong Kong, Indonesia, Egypt, United Arab Emirates, Singapore, Malaysia, and London to name a few of the more common locations (or rather, what they’ve indicated as their “network”).

Pretty neat to see it grow beyond the U.S. since it was not something we considered when the app was being built. Thankfully the db is running in UTF-8 to handle the various character sets — I’ve got at least one tag in Chinese which I can’t read but at least it renders correctly heh.

Oh, and as of this post, Describe Me has 80,249 users. Can’t wait until 100k! We’re gonna need to throw a celebration or something. :)

  • 0 Comments
  • Filed under: Facebook
  • 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.

  • 0 Comments
  • Filed under: Facebook, PHP
  • 2 Facebook apps

    Like a lot of developers, I jumped on the Facebook platform bandwagon as well. I’ve help author two Facebook apps:

    • Gamers
      • Gamers basically allows you to create a game library, add gamer tags, rate/review games, and display it all on your profile.
    • Describe Me
      • Describe Me allows you to tag people, thus building a tag cloud. Think del.icio.us, but for tagging people instead of web pages.

    If you’re on Facebook, add those apps and check them out!

  • 0 Comments
  • Filed under: Facebook