magazine resources subscribe about advertising

New Architect Daily
Commentary and updates on current events and technologies

CMP Media E-Book

Download your copy today.

Research
Search for reports and white papers from industry vendors and analysts.

This Week at NewArchitect.com Subscribe now to our free email newsletter and get notified when the site is updated with new articles







Day of Defeat Online Gaming

 New Architect > Archives > 2000 > 11 > Programming with Perl  

Simplicity in Load Balancing

By Randal L. Schwartz

I was thinking about e-commerce the other day, and chatting with my buddy Steven Lembark of Knights bridge Solutions about the typical tiny, dirty tasks related to it. He mentioned that he hadn't seen any of my columns address the task of load balancing incoming requests to Web servers, and I said, "Hey, thanks for the idea."

After chatting with Lembark for a bit, I came up with a very simple way to ensure that incoming requests are sent to the best host for processing. It's not the most elegant approach, but it's probably the fewest lines of code you'll see on this topic, so I call it the "simple load balancer." Basically, we run a daemon that gathers the load averages for the interchangeable machines in the cluster. (They're interchangeable in that they should have identical content and return the same response for the same URL.)

This daemon then writes a small database visible to a CGI script that can take an incoming URL and redirect the invoker to the same URL on the least-loaded machine, randomly redirecting the requests in proportion to the current load average. So, from the welcome page of the application, all the outgoing links are sent through this redirect script, and boom—the user ends up on the best machine at the moment. Not rocket science, but it'll do. So, let's take a look at how this works.

The System Load Average

The first script reports back the current load average on the system, and is presented in



  Day of Defeat Online Gaming

home | daily | current issue | archives | features | critical decisions | case studies | expert opinion | reviews | access | industry events | newsletter | research | careers | info centers | advertising | subscribe | subscriber service | editorial calendar | press | contacts


Copyright © 2006 CMP Media, LLC Read our privacy policy, your California privacy rights, terms of service.
SDMG Web sites: BYTE.com, C/C++ Users Journal, Developer Pipeline, Dr. Dobb's Journal, DotNetJunkies, MSDN Magazine, Sys Admin,
SD Expo, SD Magazine, SqlJunkies, The Perl Journal, Unixreview, Windows Developer Network, New Architect

web2