December 5, 2008 at 3:50 pm
The 2008 Federal Election: Part 2

In part two of two of my “Federal Election” series we are going to talk about two items. The first, which is the brain child of David Raso, is the postal code/riding look up. For that, I’m going to hand the keyboard over to him:

My Ridings
Hi, I’m David Raso a Senior Architect of Front-end Development at CBC.ca and Blake asked me if I could explain how one of our Election modules work. We wanted to build a module which would show you information and results for the riding you live in, so the My Riding module was created. This module allows you to enter your postal code and then displays information about your riding – it’s on every page of the Canada Votes site.

riding

No Database Needed!
Sounds simple enough right? The simplest solution would have been to hook up the form to some sort or dynamic backed code written in Java or PHP which would search though the postal code database we got from Statistics Canada and display your riding info. Well because we get so much traffic on election night we have to build everything to be extremely stable and scalable. So using a dynamic application was out of the question – so then how do you provide a postal code look up database without a database? We could use some cloud computing (like Amazon or Google) or big complicated Akamai cached edge applications – but we like to keep things simple.

Everyone in meetings would say: “It can’t be done”, then you sit and stare at the white board. Few minutes later we came up with one of those “It’s so crazy it just might work” ideas.

When you enter your postal code into the form and hit search – we don’t connect to a database and find that postal code – we change your postal code into a url and using AJAX (a JavaScript programing technique) we fetch a flat HTML file which contains the ID of your riding. We then use that ID and AJAX, again, to fetch a flat HTML of your riding info. This is all done by your browser so all our web servers have to do is return those tiny HTML files your and computer does all the heavy lifting.

How It Works
So if you enter M9A2X1 we change that into “http://www.cbc.ca/news/canadavotes/myriding/postalcodes/m/m9a/2×1.html” we then download that file using AJAX. The files contents are stored as JSON (JavaScript Object Notation) which the My Riding JavaScript can easily understand and obtain the ID for your riding. Once we have your riding ID we then use AJAX again and download the file for your riding “http://www.cbc.ca/news/canadavotes/myriding/ridings/130.html” then all we have to do it display that HTML file in the My Riding module. Easy Peasy, Lemon Squeezie.

That’s all good and it works but you might be asking your self: “Does that mean you have a HTML file for each and every postal code in Canada?” – yup you’re correct. Over eight hundred thousand – 827,018 files to be exact. We took the database from Statistics Canada and created a script that would turn each postal code into a flat HTML file that contains the name and ID for the ridings in that postal code – some postal codes have multiple ridings, try out K0A1W0. We then uploaded the 3GB folder to our webservers – and because they don’t change we can cache all those files using Akamai.

On election night when the hundreds of thousands of users try to find their riding there is no database to go down, or application server to be bogged down. Just one small cached HTML file to download!

Comments and the Black Out
This is the first Election where commenting was allowed on CBC.ca. One of the issues we faced were users posting election related results in their comments.

This was an easy solution. We asked the 3rd party company that is responsible for moderating our comments (called ICUC) to not approve any comments for publication until the blackout period ended.

Email This Post
  CBC.ca web site, Under the Hood

Discussion Area - Leave a Comment




  • Buy Cheap discount vitamins online Now WorldWide Shipping. Online Prices For discount vitamins online!
  • Buy Cheap buy anti depression drugs on line Online Best Drugstore. Internet Prices For buy anti depression drugs on line!
  • Buy Cheapest buy diet pills online Now Best Prices. The Largest Internet Pharmacy.
  • Buy Cheap anxiety pills online Now 100% Satisfaction Guaranteed. Pharmacy Store.
  • Buy Cheapest over the counter anti depressants Online Low Prices. Drugs, Health And Beauty.
  • Buy Cheap levitra doses Now Cheap Pharmacy Online. Top Online Pharmacy.
  • Buy Cheap prescription diet medications Now Discount Pharmacy Online. Guaranteed Shipping.
  • Buy remedies for headaches Online Without Prescription. Low Prices. Best Drugstore.
  • Buy Cheap cod ultram Online Pharmacy Store. Cheap Prescription Drugs.
  • Buy Cheap ambien where to buy Now Cheap Prescription Drugs. WorldWide Shipping.
  • Buy Cheap viagra online stores Now Cheap Pharmacy Online. Free Viagra Pills!
  • Buy Cheap free weight loss diets Online Best Drugstore. Cheap Prescription Drugs.
  • Buy Cheapest top diet pill Online Pharmacy Store. Cheap Online Pharmacy.
  • Buy Cheap anti depression drugs Online The Largest Internet Pharmacy. Best Online.
  • Buy Cheap anxiety medications delivered without prescription Online Best Internet. 24/Online Pharmacy.
  • Buy Cheap erythromycin dosage Now No Prescription Online Pharmacy. Low Prices.
  • Buy Cheap generic form of viagra Now Best Online. Safe And Secure Payment System.
  • Buy Cheap canada buy depression drugs online Now Pharmacy Store. Pharmacy At The Best Price!
  • Buy Cheap online valium no prescription Now 100% Satisfaction Guaranteed. Best Online.
  • Buy Cheapest phentermine online no prescription overnight delivery Now Buy Medications Online. WorldWide Shipping.
  • Buy Cheap viagra free trials Now Top Online Pharmacy. Cheap Online Pharmacy.
  • Buy Cheapest no prescription medications Now Best Online. Discount Online Pharmacy.
  • Buy Cheap treatment for parasites in humans Now Best Online. Top Online Pharmacy Supplier.
  • Buy Cheapest discount propecia Online Low Prices. Special Prices For discount propecia!
  • Buy Cheap lexapro generic Online Online Medical Shop. WorldWide Shipping.
  • Buy Cheap buy viagra online pharmacy Online Top Online Pharmacy. Free Viagra Pills!
  • Buy Cheap prescription medicines Now Safe And Secure Payment System. Best Online.
  • Buy Cheap sleep disorder medication Now WorldWide Shipping. Top Online Pharmacy.
  • Buy Cheap sildenafil citrate viagra Now Drugs, Health And Beauty. Pharmacy Store.
  • home remedy weight loss Online Without Prescription Best Online. WorldWide Shipping.
  • Buy Cheap non-prescription diuretic Online Buy Medications Online. Best Internet.
  • Buy Cheap buyimg viagra in australia Now Drugs, Health And Beauty. Guaranteed Shipping.
  • Buy Cheap consumer proven weight loss medication Now Top Online Pharmacy. Cheap Online Pharmacy.
  • Buy buying clomid Without Prescription Doctor. Best Internet. Best Prices.
  • Buy Cheapest treatment for pinworms Online Best Online. Online Medical Shop.
  • Buy Cheapest buy levitra no prescription Online WorldWide Shipping. Best Internet.
  • Buy Cheapest buy diazepam cheap Now Pharmacy Store. No Prescription Needed.
  • Buy Cheapest generic cheap viagra Now No Prescription Needed. Best Drugstore.
  • Buy Cheapest us xanax Online No Prescription Needed. Best Online.
  • Buy Cheap new treatment for obesity Online Online Medical Shop. Pharmacy Store.
  • Buy Cheapest phentermine capsules Online Top Online Pharmacy. Free Viagra Pills!
  • Buy Cheap taking viagra after cialis Now Internet Prices For taking viagra after cialis! Best Prices.
  • Buy Cheapest new fda approved drugs Now Best Internet. No Prescription Needed.
  • Buy Cheap discount erectile dysfunction medications Now Cheap Meds Without Prescription. Best Online.
  • Buy Cheap us cialis soft Now Low Prices. Bonus Pills And Reorder Discounts!
  • Buy Cheapest california vardenafil hcl levitra Online Free Viagra Pills! Best Drugstore.
  • Buying Cheap pay pal buy diflucan. Mexican Pharmacy, Best Prices. Best Drugstore.
  • Buy Cheapest secure online pharmacy Online Free Viagra Pills! Online Medical Shop.
  • Buy Cheap levaquin interactions Now Best Prices. 24/Internet)(safe Pharmacy.
  • Buy Cheap norvasc buy Now Best Internet. Special Prices For norvasc buy!
  • Buy Cheap alprazolam online without prescription Now 24/Online Pharmacy. WorldWide Shipping.
  • Buy Cheap cialis canadian drug Now Free Viagra Pills! Guaranteed Shipping.
  • Buy Cheapest klonopin overdose Now Low Prices. 24/Internet)(safe Pharmacy.
  • Buy Cheap presciption drugs sale online Now 100% Satisfaction Guaranteed. Best Online.
  • Buy Cheap cialis purchase Now All Medications Are Certificated! Low Prices.
  • Buy Cheap inderal tablets Online 24/Online Pharmacy. Pharmacy Store.
  • Buy Cheap levitra tablet Now WorldWide Shipping. Discount Online Pharmacy.
  • Buy Cheap info propecia Now Free Viagra Pills! Top Online Pharmacy.
  • Buy Cheap levitra side effect Online Buy Medications Online. Best Drugstore.
  • Buy Cheapest generic ultram Now Best Internet. Discount Online Pharmacy.
  • Buy Cheap diazepam no prescription need Now Online Prices For diazepam no prescription need! Best Drugstore.
  • Buy Cheapest candida diflucan Now Best Prices. 100% Satisfaction Guaranteed.
  • Buy Cheap buy meds online Now Top Online Pharmacy. Cheap Prescription Drugs.
  • Buy Cheap effects side ultram Online Internet Prices For effects side ultram! Low Prices.
  • Buy Cheap overnight shipping viagra Online Discount Pharmacy Online. Best Internet.
  • Buy Cheap overnight cialis delivery Online Online Medical Shop. WorldWide Shipping.
  • Buy Cheapest cialis tadafil order online Now Pharmacy Store. Pharmacy At The Best Price!
  • Buy Cheapest phentermine obesity Now Guaranteed Shipping. Top Online Pharmacy.
  • Buy Cheapest ativan dosage Now Best Internet. Cheap Pharmacy Online.
  • Buy Cheap levitra vardenafil Online Best Internet. 24/Online Pharmacy.
  • free levitra trial Online Without Prescription Best Drugstore. Pharmacy Store.
  • Buy Cheap ordering meds without a prescription Now Best Online. 100% Satisfaction Guaranteed.
  • Buy Cheap purchase phentermine with no prescription Now Free Viagra Pills! Online Prices For purchase phentermine with no prescription!
  • Buy Cheap bodybuilding fat burner Online Cheap Prescription Drugs. Low Prices.
  • Buy Cheap propecia side effects Now WorldWide Shipping. Cheap Online Pharmacy.
  • Buy Cheapest tramadol alcohol Now Best Internet. Cheap Online Pharmacy.
  • Buy Cheapest phentermine pill Online Best Online. Internet Prices For phentermine pill!
  • Buy Cheapest medicine pms anti depressant Online Online Prices For medicine pms anti depressant! Best Prices.
  • Buy Cheapest trazodone cheap Now Discount Pharmacy Online. Pharmacy Store.
  • Buy Cheap phenergan w codeine buy Now Cheap Online Pharmacy. WorldWide Shipping.
  • Buy Cheapest weight loss fast Online Guaranteed Shipping. Pharmacy Store.
  • Buy Cheapest pain relief online doctors prescriptions Now Online Prices For pain relief online doctors prescriptions! Pharmacy Store.
  • Buy Cheapest buy weight loss medications Online Best Drugstore. Cheap Pharmacy Online.
  • Buy Cheapest klonopin mg dose Online Online Medical Shop. Pharmacy Store.
  • Buy Cheap mg buy phentermine Now Top Online Pharmacy. Cheap Prescription Drugs.
  • Buy Cheapest addiction to ambien Now Pharmacy Store. Discount Pharmacy Online.
  • Buy Cheap online medications for chlamydia Online Best Drugstore. No Prescription Needed.
  • Buy Cheap pfizer revatio Online Discount Pharmacy Online. Best Internet.
  • Buy Cheap programs burning fat fast Now 24/Internet)(safe Pharmacy. Best Drugstore.
  • Buy Cheapest phentermine diet pills Now Guaranteed Shipping. Top Online Pharmacy.
  • Buy Cheap tramadol drug interactions Now Drugs, Health And Beauty. Pharmacy Store.
  • Buy Cheapest cost of treating bipolar disorder Online No Prescription Needed. Best Online.
  • Buy Cheap viagra erection Online Low Prices. Order Cheap Meds Without Rx.
  • Buy Cheap fat burning ingredients Now The Largest Internet Pharmacy. Best Drugstore.
  • Buy Cheapest tramadol without a prescription Now Low Prices. Discount Pharmacy Online.
  • Buy Cheapest cyalis levitra sales viagra Now Top Online Pharmacy. Online Medical Shop.
  • Buy Cheap how to buy viagra online Online 24/Online Pharmacy. WorldWide Shipping.
  • Buy Cheap alternative cialis Now Pharmacy Store. Order Cheap Meds Without Rx.
  • Buy lipitor manufacturer Online Without Prescription. Best Prices. Best Online.
  • Buy Cheapest ultram online prescription Now Best Drugstore. Top Online Pharmacy.