
Tips being coins and tricks being a magic trick to make a big coin.
My site keeps going down from excessive bandwidth consumption! How do I fix this?
Last updated: around 2003
Type: Tip
Reliability:
- Low
Ease of learning:
- Easy-medium
Time saving:
- Small gain
Usefulness:
- Moderately useful
Difficulty:
- Medium
Overall:
- Mediocre
1 Introduction
If you're consuming too much bandwidth, often, you need to cut down on the file sizes of your files like images. If it's merely a high traffic issue (a very high number of visitors), then consider getting your own paid webhost. I use edatarack.com as my webhost which gives over 100 times the bandwidth and disk space allowance as Angelfire Free does (and most any other free webhost at that matter) and only costs $3.95 a month (paid annually). Some paid webhosts have no bandwidth limits, others are extremely high such as 1 TiB a month (a thousand times that of free webhosts - TiB is tebibyte, about 1.1 trillion bytes).
What is bandwidth you might ask? If you're not much of an internet expert, bandwidth is basically the amount of data being transferred between the webhost (the server) to your computer for viewing. If ten downloads of a 40,000-byte image were completed in full, that'd use up 400,000 bytes (or about 390 KiB) in bandwidth for those downloads. If there were a thousand downloads, it'd be 40 million bytes instead (38.1 MiB). Bandwidth includes all files, not just web pages, images, music, ZIP files, executables, anything.
2 About optimization
2.1 Some "cheap" techniques
Over the internet, file size is everything and can make or break the game if it's ridiculous. If you've happened to have seen something in the FAQ page and in two other areas of my site, you've probably seen videos [or even downloaded one or two]. Compression is what really matters. Compressed files not only help saving some room on your hard drive, but it shortens download time, reduces your bandwidth consumption, and saves your limited disk space you have. Over a regular dial-up connection (aka high-speed dial-up), it would take 9 hours to download my biggest 140 MB video [however, with something like NetZero high-speed, it may only reduce to about 1 hour or less, because of file compression [the advertisement says up to 5 times faster, wrong, it can be much faster, even 50 times, depending highly on the file downloaded]]. Compressing it would reduce it to maybe 20 seconds, a gigantic difference. All my videos compress so well that they are far better than what MP3 could even get! Sometimes, a single 320x240 frame at 24-bit color can be only 7 bytes!
Images are very common on the internet everywhere. I have quite a few images on my site myself, but they are fully optimized for file size and file compression. The topic banner above, the tipsntricks figure, is also optimized. I tend to run a GIF versus PNG test and upload whichever is the smallest in file size. Though one byte may not seem like much, it does add up, especially after a few thousand downloads. When using drawings from your graphics editor, avoid saving in JPG as with GIF or PNG, it would look much better and compress far better [unless you used some very high-powered special effect]. For photos, JPG is almost always better. For general screenshots of things in Windows, use PNG. For any video game screenshot, use JPG unless the scene is very empty with nothing there.
You can enlarge or shrink an image indirectly by adding the width="x" and height="y" attributes within the image tag [if you're using a standard HTML editor [where you write the code]]. This can save a lot of disk space, and magnifying an image by twice the size isn't too bad, but much more is not recommended unless there's a good reason for it. Also, crop your images in as much as you can without ruining your image. This may have minimal effect though, especially with JPG images like photos. With GIF and PNG, avoid interlacing as that adds another 100 bytes or so.
2.2 More decent techniques
Here's a complete list on how to reduce your bandwidth:
- Try limiting the page size to no more than 50KB if at all possible, and that includes the HTML, pictures, and everything else you have. If you run on a high bandwidth server or webhost (almost always a paid one), then limit it to no more than 300 KB.
- If you use the same picture along several different pages [like I have here on my site, you can see the same picture from as many as ten different pages], or even the same page, it doesn't cost any bandwidth, because the computer stores it in the cache to refer off of from there. However, some users do clear out their cache once in a while, so they still do take some bandwidth away, but it wouldn't be as intense.
- For really large pictures, of GIF or PNG format, try resizing them to half their width and height, and then expand them out to double their size. This really doesn't distort them too much, but at least it keeps the main quality. Those with large monitors and a low resolution may find this highly noticable. Avoid doing this with JPGs, however.
- Also, for really large pictures, try using a lower quality picture if possible. This mainly works with JPGs only though, and they often hog up a lot of space.
- Use reasonable-sized thumbnails and allow for users to click on them to view a larger version.
- Run tests. For simple drawings and diagrams, save a bitmap file version as GIF and PNG and use whichever is smaller. This doesn't make that much of a difference though, but it adds up to around 300 bytes per image on average. For JPG, save a bitmap image at various qualities for JPG. I suggest saving at 90, 80, 70, and 60. If there's a big drop along the way, use it. If they are evenly spaced, use the lowest quality one that looks good to you. Though this can take a lot of extra time, it can eventually lead to saving bandwidth.
- Avoid music and multimedia as they really hog up disk space. A 3-minute song at the MP3 standard (128 Kbps CBR, stereo, 44,100 Hz) will consume 2880 KB, or 2.81 MB of disk space, very big for a webpage. Instead, use mono and especially ABR, and perhaps downsample it to 32,000 Hz. ABR allows for the halving of disk space along with using mono.
There is a formula to estimate your bandwidth consumption. I think it goes as follows:
BAN=(DSU÷PC)×TPV
In this formula, BAN is what your bandwidth value is. DSU is disk space used for all your files. PC is your total page count [the number of readable documents you have]. TPV is your traffic page views or the number of visitors you have that read some of your pages.
Footnotes:
* Dithering and how it's used is explained in high-details on this neat report.
[an error occurred while processing this directive]