Thursday, July 7th, 2005

Showcase: Apple.com iTunes Counter

Category: Showcase

Apple.com is currently displaying an iTunes Counter that shows the number of songs downloaded, counting to the 500 million song mark.

The countdown actually uses Ajax to grab the counts from an XML that is generated and put on the server at http://www.apple.com/itunes/external_counter.xml:

<root>
<count name="curCount" timestamp="Thu, 07 Jul 2005 04:51:01 GMT">484126216</count>
<count name="preCount" timestamp="Thu, 07 Jul 2005 04:46:00 GMT">484120405</count>
</root>

I wonder if they just have cron kick out a “select count(*) from …… | mysql | munge > external_counter.xml” every minute ;)

Our friend Dunstan has his hands all over, as you can see in comments (//dunstan). It looks like they increment the count, and sync up every now and then (minute) via Ajax to get the real count. Smart.

It is also interesting how they just hack on top of XHR, and aren’t using any helper toolkits.

itunes-countdown.jpg

Posted by Dion Almaer at 12:05 am
7 Comments

++---
2.9 rating from 13 votes

7 Comments »

Comments feed

“I wonder if they just have cron kick out a ‘select count(*)…'”

Gosh, I hope not. “select count(1)” is much faster. ;)

Comment by Eric Thompson — July 7, 2005

I hadn’t realized that itunes has already gotten up to the 500million mark, they’ve grown at a rapid pace. I think they are doing great things. Although I don’t like purchasing music online, nor will I, I still support them.

I’m old school and I like to buy the cds and have a phyical copy of it instead of only having a digital copy. That’s just the way I am, so I like it : )

Comment by Jonathan — July 7, 2005

I think the count is updating every five minutes instead of every minute.

Jonathan: Are digital bits on a hard drive less physical than digital bits on a CD?

Kennedy

Comment by Jack Kennedy — July 7, 2005

The server’s pulling down the stats every minute, but the stats are only changed every five minutes. The stats show current songs and songs five minutes ago. From that, the browser effectively calculates songs per millisecond and repaints every 100 milliseconds.

I was curious so I wrote up a walkthrough here.

Comment by Michael Mahemoff — July 8, 2005

I think the link was filtered out, how about this:

http://www.softwareas.com/ajaxian-guesstimate-on-download-counter

Comment by Michael Mahemoff — July 8, 2005

Might be cool to add an averaging feature which keeps track of the true increase every 5 minutes as updates come from the server, so the estimated in-between updates could (ideally) become more accurate over time.

Comment by Scott Schiller — July 8, 2005

Looking at the script, I got a kick out of the ie:mac filter (they show a static image):

“Upgrade to Safari to see the countdown to 500,000,000 songs.”

http://images.apple.com/home/2005/images/itmscounteriemac20050705.gif

An amusing browser upgrade pitch if I ever saw one. ;)

Comment by Scott Schiller — July 8, 2005

Leave a comment

You must be logged in to post a comment.