Search
Lori MacVittie - Two Different Socks
You are here: DevCentral > Weblogs

posted on Tuesday, March 31, 2009 4:13 AM

Long URLs and variable names increase transfer size which wastes bandwidth and money

o3 magazine has a great article on the impact of long URLs on bandwidth; specifically on how much bandwidth is wasted by excessively long URLs and variable names within HTML, JavaScript, and CSS selectors.

What the author does not mention, and he really should, is that wasting bandwidth can translate into wasted dollars, as well. This is particularly true of applications that might be hosted in a cloud environment, as well as those delivered across WAN links provisioned with bursting capabilities above limits for which organizations are usually charged a premium price.

For example, using the analysis by o3 on the amount of “wasted” bandwidth and combing that with the cost per GB transferred through Amazon EC2 leads to a not insignificant dollar amount that is effectively thrown into the bit-bucket every month.

imagePerhaps a valid point until the concept is applied to the 100+ character URL happy Facebook home.php page. There are roughly 150 source file references on this page, and rounding down to about 100 HREF requests for arguments sake. Being generous, assuming 80 bytes of waste per URL. Thats 12000 bytes of upstream, and 20000 bytes of downstream waste. So using data again from compete.com, facebook has 1,273,004,274 visits per month. This is roughly 41,064,654 requests per day. So on a single day, the folks over at facebook have wasted roughly 783GB downstream and 469GB upstream. This works out to be 74Mbit/sec downstream and 44MBit/sec upstream of bandwidth.image

Based on the amount of “waste” and assuming Facebook was using EC2 instead of its own solution, this would translate into $158.03 a day for a total of approximately $4,740 / month. That would be nearly $56,780 a year wasted.

But you’re not Facebook, right? You’d never have that kind of traffic in a single day. Let’s assume for a minute that those totals are per month, instead. In that case, you’d have wasted a mere $158.03 per month or approximately $2160 a year. Not quite so bad, right?

Before you dismiss that as irrelevant, let’s translate that into the number of hours you could run your application on an EC2 instance.

Instance Hours Days (24/7)
Small Linux/UNIX 21600 900
Extra Large Linux/UNIX 2700 112.5
Small Windows 17280 720
Large Windows 2160 90

Essentially, if you’re running a small Linux/UNIX instance then the money you could save from smaller URLs over one year would allow you to run that same instance for nearly 2.5 years.

Doesn’t seem so irrelevant now, does it?

There are similar bandwidth-associated cost savings if you’re leasing bandwidth and are charged a premium for bursting over your contracted bandwidth. The amount, of course, will vary based on what you’re being charged for the overdraft on your bandwidth. A burstable T1 is common for small and medium sized businesses as it is highly cost effective, cutting the operating expense for a T1 about in half. But if you’re constantly bursting at nearly full T1 capacity (1.544 Mbps) then you’re going to end up paying more. Reducing the size of URLs and JavaScript variables can ensure that you stay in a lower pricing tier, thus ensuring that the recurring operating expense is reduced.

If you have access to a network-side scripting solution, you can automatically shorten URLs in application responses and subsequently map them back to the appropriate internal, long URL on request. The author of the article claims this puts undue stress on application delivery controllers, but rewriting URLs is one of the core capabilities for which an application delivery controller is optimized, so the burden isn’t nearly as stressful as the author implies. Even assuming an addition of 2-3% utilization on the application delivery controller yields a higher benefit in saved bandwidth and operating expenses than any cost associated with such a slight increase. You can also use mod_rewrite to affect such a change if you’re running Apache internally, which will also increase utilization of server resources but also provide similar benefits to an application delivery controller in terms of rewriting URLs. 

The reasons for using a network-side scripting solution to make such changes to URLs generally revolve around the time and effort involved in rewriting the application. Such an effort may not be seen as having sufficient ROI on bandwidth savings to prioritize, so using a network-side scripting solution eliminates the need for developer resources (and associated testing and deployment costs) and affects change in a more immediate fashion.

If you’re just starting development on a project, whether you’re planning on hosting in the cloud or locally, consider the ramifications on bandwidth and associated costs from long URLs and excessively long variable names. Reducing the size of these aspects of an application up front can result in considerable savings in the long run.

 

Follow me on Twitter View Lori's profile on SlideShare friendfeedicon_facebook AddThis Feed Button Bookmark and Share

Reblog this post [with Zemanta]


Feedback

3/31/2009 9:28 AM
Gravatar Sorry, but I don't buy it.

The problem is that you're comparing the cost of VM instances to bandwidth savings instead of the cost of human time to bandwidth savings. In Facebook's case, the engineering cost and related QA most likely far exceeds $56k/yr. For a smaller site, a few hundred dollars a month barely amounts of half a day of work. If your time has no value (sweat equity) and your dollars are limited, sure, this makes sense. But it is also unlikely you've bought an ADC too.

Using an app delivery controller to reduce the engineering cost simply shifts the expense around. You're still on the hook to come up with all of the rewrites, test them all, and deal with all the squirrely cases where JavaScript generates dynamic URLs. That's QA time, ops time, likely engineering time, and even then you've managed to slow down your ADC with lots of rules that means having to examine whether you need to scale your ADC solution up.

The driver for moving to shorter URLs should be improved end user experience. Even then, shorter URLs tend to be lower in the queue of things to fix. Those wins only tend to kick in if the request/response headers actually make up a non-trivial part of the transaction. E.g., Google's top level without a cookie jar yields 2 packets compressed. A long URL, especially one that pushes the request size into another packet, will make for a much more significant difference.

If you are looking for something interesting, obscenely long cookies are a good culprit. There are a lot of applications (especially enterprise ones, including a well known security layer) that generates downright obscene cookie sizes. With cookie playback on a per-request basis, a 4-5k cookie is far more insidious than a 150 byte URL. If the app firewall module can do something like an SSL-VPN cookie jar, that could be truly interesting.
Steve Shah
3/31/2009 9:35 AM
Gravatar Interesting point, re: cookies. They definitely are large, and there are quite a few of them today - almost no web application today is cookieless.

Thanks for the opinion, and the pointer in that direction. I'll look into cookie-jar functionality and see what can I can come up with. Definitely worth the effort.

Lori
Lori MacVittie
4/1/2009 8:21 AM
Gravatar I'm a fan of descriptive javascript variable names... Things like...
UserWantsSaveAckReportGVYesNo

:-P

Don.
Don MacVittie
4/1/2009 8:51 AM
Gravatar Yeah, but C back then had a limit on the length of variables - 32 characters. There's no such limitations in JavaScript. So today, our favorite long variable name friend could be even more descriptive and use:

DoesTheUserWantToSaveTheACKReport_GlobalVariable_OptionsAreYesOrNo_TypeIsBoolean

Aren't you glad you don't have to deal with that now?

:-)

Lori
Lori MacVittie
8/22/2009 9:23 AM
Gravatar Tofranil.
Tofranil-pm side effects.

Let Me Know What You Think


Please use the form below if you have any comments, questions, or suggestions.

Title:
 
Name:
 
Email: (so we can show your gravatar)
Website:
Comment: Allowed tags: blockquote, a, strong, em, p, u, strike, super, sub, code
 
Please add 7 and 6 and type the answer here:

Blog Stats

Posts:980
Comments:1685
Stories:0
Trackbacks:583
  

Image Galleries

  

Application Delivery

  

Cloud Computing

  

Random

  

Security

  

Chat Catcher

82,243 Members in 102 Countries and Growing!

Join DevCentral Today!

About DevCentral

DevCentral has been a successful, thriving community for many years. We have always strived to bring you the best technical documentation, discussion forums, blogs, media and much more that we can.

So dive in, get familiar with DevCentral. We hope you like it, we hope it makes your job easier, and lets you get that much more power out of the community. To learn more, make sure to check out the Getting Started section. And if you have any problems, or think something could be easier to use, drop us a line to let us know.

Got It !

We've received your comment and transmitted it directly to DevCentral HQ.

Thanks for taking time to let us know what's on your mind. At DevCentral | Community Matters!

Get In Touch With Us

Have questions, suggestions or just want to get something off your chest?

Use our handy form below to Direct Connect with DevCentral Mission Control.

Send Us Feedback       or