We've learned a thing or 10 about hosting high traffic promotions through our live events platform. These promotions get a lot of attention very fast with little room for error.
The results of this expertise is clear in fast page loads and low downtime, but what happens behind the scenes? Today starts a three-part series from some of our tech team to explain, in laymen's terms, how this happens.
Fun fact: It's not really fast hamsters! Read on to find out.
During a live event, our servers have a lot of work to do. A virtual army of robotic minions scurry back and forth, fulfilling requests and filing data a lot like waiters in a busy restaurant.
Our servers respond in a timely manner to a variety of tasks when a visitor loads a page. For example, they'll use reCAPTCHA to verify a user is human, they'll recognize returning visitors, store new registrants’ information and the list goes on. Each of these actions takes a small amount of time on the server side and on their own they're relatively simple tasks.
However when the tasks start to stack up, as they do during a live event, our servers get a chance to shine.
Slow Service is Unacceptable Service
A live event is like a crowded restaurant with many guests to serve. When a new guest walks through the door of a restaurant, they’re greeted, led through the busy dining room to be seated at a table where a waiter takes their order. The waiter passes that order along to the kitchen staff who prepare the food. Once it’s ready, the waiter delivers it to the guest at their table.
With a traditional data server—one designed for serving lower levels of traffic—each of the “waiters” stands around waiting for their next task, ignoring the diners at other tables who need to be served their content. In a restaurant this slow service affects the diner's experience, and slow service on the Internet is arguably less tolerable to consumers. To fix this problem, we had to find a solution that was decidedly unconventional.
Node.JS To The Rescue
A restaurant wait staff must move gracefully from table to table, answering questions, taking orders and sending them off to the kitchen as fast as possible. That's how we want our servers to function, and this is where Node.js comes in.
Node.js is a server platform written in the language of the Internet unlike a conventional web server. It responds to events—like a request from a visitor or a response from a database—when they occur and never has to sit still while it’s waiting for something to happen.
Do One Thing Well
Node.js allows each of our servers to handle more visitors at the same time, but it’s not the only piece of the puzzle. In order for our servers to handle requests as quickly as possible, we need to make sure that they’re not doing anything unnecessary or time-consuming.
In a restaurant that means writing good menus, hiring a hostess, and properly staffing the kitchen. For a high-traffic data server, we build client-side apps, similar to those used by Twitter and Facebook, which run in the visitor’s browser and take a lot of work off the server’s plate, and we use load balancers to make sure requests are evenly distributed between servers.
Keep It Moving
Finally, we build a message-queuing system to do any work that the server doesn’t need to do immediately. Using a message queuing system is like putting a smartphone in every waiter's hand to take orders and send them wirelessly to the kitchen. Eliminating the visit to the kitchen to deliver orders allows each waiter to respond faster and move along to the next table more quickly, and so it is with our web servers.
When all these pieces are set in motion, our servers hum along happily under traffic that would bring a conventional system crashing to its knees. Each request is handled and responded to smoothly and delayed action items are queued for other systems to work on. Our imaginary restaurant is in constant, fluid motion, and our virtual diners leave with full stomachs and smiles on their faces.
David Straub is a Software Engineer at HelloWorld you can find him on Twitter @DavidMStraub and connect with him on Linkedin here. Check back next week for another in our behind the scenes look at the mechanics of the live event.
PSST: We're talking Live Events at SXSW on March 12th in Austin with the CMA, iHeartRadio and Live Nation.
Will you be there? Let us know and let's connect. You can find more information right here.