Benefits & Drawbacks Of: Dissertation
Benefits & Drawbacks Of: Dissertation
ON
IN PARTIAL FULFILMENT
OF
GUJARAT UNIVERSITY
SUBMITTED BY:
Chintan Parikh
Nihar Dave
Benefits and Drawbacks of HTTP Data Compression
ACKNOWLEDGEMENT
The Dissertation gives us the feeling of fulfillment & deep gratitude towards all our
teachers, friends and colleagues. As the final frontier towards achievement of my master’s degree,
the activity of going through the dissertation has bridged the gap between the academics and the
research work for us. It has prepared us to apply ourselves better to become good computer
Professionals. Since we were beginners it required lot of support from different people. We
acknowledge all the help we have received from so many people in accomplishing this project
and wish to thank them.
We take this opportunity to thank Mr. H.K DESAI, director of I.I.T.E. for taking
personal interest in the project and guidance which often resulted into valuable tips. We also
thank our guide MR.VRUTIK SHAH for his regular guidance and for his encouragement to us.
Our sincere thanks to our batch mates, who have provided us with innumerable
discussions on many technicalities and friendly tips without their cordial support his activity
would have been much tougher.
Table of Contents
1. Overview of HTTP Compression...............................................................................................7
1.1 Abstract...............................................................................................................................7
1.2 Introduction........................................................................................................................8
1.3 Benefits of HTTP Compression........................................................................................10
2.0 Process Flow...........................................................................................................................12
2.1 Negotiation Process................................................................................................................12
2.2 Client send request to the server.............................................................................................13
2.3 Server send Response to the Client.........................................................................................13
3.1 Popular Compression Techniques...........................................................................................14
3.2 Modem Compression..............................................................................................................15
3.3 GZIP.......................................................................................................................................17
3.3.1 Introduction.........................................................................................................................17
HTTP Request and Response(Uncompressed).................................................................17
So what’s the problem?.............................................................................................................17
3.3.2 Purpose................................................................................................................................18
3.4 HTTP Compression................................................................................................................19
3.5 Static Compression.................................................................................................................20
3.6 Content and Transfer encoding...............................................................................................21
4.0 HTTP’s Support for Compression..........................................................................................23
4.1 HTTP/1.0................................................................................................................................23
4.2 HTTP/1.1................................................................................................................................23
4.3 Content Coding Values...........................................................................................................24
5.0 Approaches to HTTP Compression........................................................................................26
5.1 HTTP Compression on Servers...............................................................................................26
5.2 HTTP Compression on Software-based Load Balancers........................................................26
5.3 HTTP Compression on ASIC-based Load Balancers..............................................................27
5.4 HTTP Compression on a Purpose-built HTTP Compression Device......................................28
6.0 Browser Support for Compression..........................................................................................30
7.0 Client Side Compression Issues..............................................................................................32
8.0 Web Server Support for Compression....................................................................................34
8.1 IIS...........................................................................................................................................34
8.2 Apache....................................................................................................................................35
Table of Figure
3.1 Http Request & Response (uncompressed)……………………………………………..25
3.2 Http Request & Response (compressed)………………………………………………..25
11.1 The total page size (including HTML and embedded resources) for the top ten web
sites……………………………………………………………………………………53
11.2 Benchmarking results for the retrieval of the Google HTML file from the Apache
Server…………………………………………………………………………………58
11.3 Benchmarking results for the retrieval of the Yahoo HTML file from the Apache
Server…………………………………………………………………………………59
11.4 Benchmarking results for the retrieval of the AOL HTML file from the Apache
Server…………………………………………………………………………………60
11.5 Benchmarking results for the retrieval of the eBay HTML file from the Apache
Server…………………………………………………………………………………61
11.6 Benchmarking results for the retrieval of the Google HTML file from the IIS
Server…………………………………………………………………………………64
11.7 Benchmarking results for the retrieval of the Yahoo HTML file from the IIS
Server…………………………………………………………………………………65
11.8 Benchmarking results for the retrieval of the AOL HTML file from the IIS
Server…………............................................................................................................66
11.9 Benchmarking results for the retrieval of the eBay HTML file from the IIS
Server……………………………………………………………………………….67
11.10 HTTP response header from an IIS Server after a request for an uncompressed .asp
resource…………………………………………………………………………….68
11.11 HTTP response header from an IIS Server after a request for a compressed .asp
resource…………………………………………………………………………….69
Tables of Tables
11.1 Comparison of the total compression ratios of level 1 and level 9 gzip encoding for the indicated
URLs……………………………………………………………………………………………54
11.2 Estimated saturation points for the Apache web server based on repeated client requests for the
indicated Document…………………………………………………………………...62
11.3 Average response time (in milliseconds) for the Apache server to respond to requests for compressed
and uncompressed static documents………………………………………………………………….62
Chapter 1
1. Overview of HTTP Compression
1.1 Abstract
HTTP compression addresses some of the performance problems of the
Web by attempting to reduce the size of resources transferred between a server and client
thereby conserving bandwidth and reducing user perceived latency.
Currently, most modern browsers and web servers support some form of
content compression. Additionally, a number of browsers are able to perform streaming
decompression of gzipped content. Despite this existing support for HTTP compression,
it remains an underutilized feature of the Web today. This can perhaps be explained, in
part, by the fact that there currently exists little proxy support for the Vary header, which
is necessary for a proxy cache to correctly store and handle compressed content.
1.2 Introduction
User perceived latency is one of the main performance problems plaguing
the World Wide Web today. At one point or another every Internet user has experienced
just how painfully slow the “World Wide Wait” can be. As a result, there has been a
great deal of research and development focused on improving Web performance
Encoding schemes for such text resources must provide lossless data
compression. As the name implies, a lossless data compression algorithm is one that can
recreate the original data, bit-for-bit, from a compressed file. One can easily imagine how
the loss or alteration of a single bit in an HTML file could affect its meaning.
the weakest link or longest mile in a data transfer; hence methods to reduce download
times are especially pertinent to these users.
Currently, most modern browsers and web servers support some form of
content compression. Additionally, a number of browsers are able to perform streaming
decompression of gzipped content. This means that, for instance, such a browser could
decompress and parse a gzipped HTML file as each successive packet of data arrives
rather than having to wait for the entire file to be retrieved before decompressing. Despite
all of the aforementioned benefits and the existing support for HTTP compression, it
remains an underutilized feature of the Web today. This can perhaps be explained, in
part, by the fact that there currently exists little proxy support for the Vary header, as we
shall see later, which is necessary for a proxy cache to correctly store and handle
compressed content.
Most Web sites would benefit from serving compressed HTTP data. Infect
most site images in GIF and JPEG formats are already compressed and do not compress
much more using HTTP compression. But what about the HTML code? Currently, the
base page is compressible text, as are JavaScript, cascading style sheets, XML, and
more. Using HTTP compression, static or on-the-fly-generated HTML content can be
reduced. A typical 30 KB HTML home page can be compressed to 6 KB, with no loss of
fidelity. This lossless compression provides for the exact same content to be rendered on
a user’s browser, but the content is represented with fewer bits. This results in less time
being required to transfer fewer bits.
Chapter 2
2.0 Process Flow
First, the client (a web browser) includes with every HTTP request a
header field indicating its ability to accept compressed content. The header may look
similar to the following: “Accept-Encoding: gzip, deflate”. In this example the client is
indicating that it can handle resources compressed in either the gzip or deflate format.
The server, upon receiving the HTTP request, examines the Accept-Encoding field. The
server may not support any of the indicated encoding formats and would simply send the
requested resource uncompressed. However, in the case where the server can handle such
encoding it then decides if it should compress the requested resource based on its
Content-Type or filename extension. In most cases it is up to the site administrator to
specify which resources the server should compress.
Usually one would only want to compress text resources, such as HTML
and CGI output, as opposed to images, as explained above. For this example we will
assume that the server supports gzip encoding and successfully determines that it should
compress the resource being requested. The server would include a field similar to
“Content-Encoding: gzip” in the reply header and then include the gzipped resource in
the body of the reply message. The client would receive the reply from the server,
analyze the headers, see that the resource is gzipped and then perform the necessary
decoding in order to produce the original, uncompressed resource [9].
With this request, the Web browsers asks for the object "/index.html" on
host "www.http-compression.com". The browser identifies itself as "Firefox/1.0" and
claims that it can understand HTTP responses in gzip format.
HTTP/1.1 200 OK
Server: Apache
Content-Type: text/html
Content-Encoding: gzip
Content-Length: 26395
With this response, the Web server tells the browser with status code 200
that he could fulfil the request. In the next line, the Web server identifies itself as Apache.
The line "Content-Type" says that it's an HTML document. The response header
"Content-Encoding" informs the browser that the following data is compressed with gzip.
Finally, the length of the compressed data is stated.
Chapter 3
3.0 Compression Techniques
The main metric for data compression algorithms is the compression ratio,
which refers to the ratio of the size of the original data to the size of the compressed data.
For example, if we had a 100 kilobyte file and were able to compress it down to only 20
kilobytes we would say the compression ratio is 5-to-1, or 80%. The contents of a file,
particularly the redundancy and orderliness of the data, can strongly affect the
compression ratio.
Modem compression only works over small blocks of fixed length data,
called frames, rather than on a large chunk of a file as is the case with high-level
algorithms such as gzip. An algorithm constantly monitors the compressibility of these
frames to determine whether it should send the compressed or uncompressed version of
the frame. Modems can quickly switch between compressed and transparent mode
through use of a special escape code.
Furthermore, modems only offer point to- point compression. It is only
when the data is transferred on the analog line, usually between an end user and an
Internet Service Provider, that the data is compressed. HTTP compression would thus
generally be considered superior since it provides an end-to-end solution between the
origin server and the end user.
plaintext and gzipped HTML files were transferred over a 28.8 Kbps modem that
supported the V.42bis compression protocol, which is a predecessor to the V.44 protocol.
The algorithm used in the V.42bis protocol is similar to that of the V.44 protocol
described above; however, it is less efficient in terms of speed and memory requirements
and usually achieves a lower compression ratio for an identical resource compared to
V.44. The size of the plaintext documents in the experiment ranged from approximately
six to 365 kilobytes. Seven trials were run for each HTML file and the average transfer
time in every case was less for the gzipped file versus the plaintext file. So, the authors
concluded that, while the tests showed that modem compression does work, it is not
nearly as effective as a high level compression algorithm for reducing transfer time.
3.3 GZIP
3.3.1 Introduction
This specification defines a lossless compressed data format that is
compatible with the widely used GZIP utility. The format includes a cyclic redundancy
check value for detecting data corruption. The format presently uses the DEFLATE
method of compression but can be easily extended to use other compression methods.
The format can be implemented readily in a manner not covered by patents.
Before we start I should explain what content encoding is. When you
request a file like http://www.yahoo.com/index.html, your browser talks to a web server.
The conversation goes a little like this:
And what’s the plan when a file’s too big? Zip it![5]
because the page loaded quickly[5]. The browser-server conversation might look like
this:
3.3.2 Purpose
The purpose of this specification is to define a lossless compressed data format that:
Is independent of CPU type, operating system, file system, and character set, and
hence can be used for interchange;
Can compress or decompress a data stream (as opposed to a randomly accessible
file) to produce another data stream, using only an a priori bounded amount of
intermediate storage, and hence can be used in data communications or similar
structures such as Unix filters;
Compresses data with efficiency comparable to the best currently available
general-purpose compression methods, and in particular considerably better than
the “compress” program;
Can be implemented readily in a manner not covered by patents, and hence can be
practiced freely;
Is compatible with the file format produced by the current widely used gzip
utility, in that conforming decompressors will be able to read data produced by
the existing gzip compressor.
The data format defined by this specification does not attempt to:
GZIP is a freely available compressor available within the JRE and the SDK as
Java.util.zip.GZIPInputStream and Java.util.zip.GZIPOutputStream.
The Command line versions are available with most Unix Operating Systems, Windows
Unix Toolkits (Cygwin and MKS), or they are dowloadable for a plethora of operating
systems at http://www.gzip.org/.
One can get the highest degree of compression using gzip to compress an uncompressed
jar file vs. compressing a compressed jar file, the downside is that the file may be stored
uncompressed on the target systems.
Here is an example:
Compressing using gzip on a jar file containing individual deflated entries.
Notepad.jar 46.25 kb
Notepad.jar.gz 43.00 kb
Compressing using gzip on a jar file containing "stored" entries
Notepad.jar 987.47 kb
Notepad.jar.gz 32.47 kb
As you can see the download size can be reduced by 14% using uncompressed jar, versus
3% using compressed jar file.
Most images used in Web applications (for example, GIF and JPG) are
already in compressed format and do not compress much further; certainly no discernible
performance is gained by another incremental compression of these files. However, static
or on-the-fly created HTML content contains only plain text and is ideal for compression.
The focus of HTTP compression is to enable the Web site to serve fewer bytes of
data. For this to work effectively, a couple of things are required:
The browser should decompress the data and display the pages in the usual
manner
So what's the hold-up in this seemingly simple process? The recommendations for
HTTP compression were stipulated by the IETF (Internet Engineering Task Force) while
specifying the protocol specifications of HTTP 1.1. The publicly available gzip
compression format was intended to be the compression algorithm. Popular browsers
have already implemented the decompression feature and were ready to receive the
encoded data (as per the HTTP 1.1 protocol specifications), but HTTP compression on
the Web server side was not implemented as quickly nor in a serious manner.
Static compression, though, is not useful when the content has to be generated
dynamically, such as on e-commerce sites or on sites which are driven by applications
and databases. The better solution is to compress the data on the fly.
The IETF's standard for compressing HTTP contents includes two levels of
encoding: content encoding and transfer encoding. Content encoding applies to methods
of encoding and compression that have been already applied to documents before the
Web user requests them. This is also known as pre-compressing pages or static
compression. This concept never really caught on because of the complex file-
maintenance burden it represents and few Internet sites use pre-compressed pages.
On the other hand, transfer encoding applies to methods of encoding during the
actual transmission of the data.
The browsers, taking the cue from IETF recommendations, implemented the
Accept Encoding feature by 1998-99. This allows browsers to receive and decompress
files compressed using the public algorithms. In this case, the HTTP request header fields
sent from the browser indicate that the browser is capable of receiving encoded
information. When the Web server receives this request, it can
1. Send pre-compressed files as requested. If they are not available, then it can:
2. Compress the requested static files, send the compressed data, and keep the
compressed file in a temporary directory for further requests; or
3. If transfer encoding is implemented, compress the Web server output on the fly.
The feature of compressing Web server dynamic output on the fly wasn't
seriously considered until recently, since its importance is only now being realized. So,
sending dynamically compressed HTTP data over the network has remained a dream
even though many browsers were ready to receive the compressed formats.
Chapter 4
4.0 HTTP’s Support for Compression
HTTP compression has been around since the day of HTTP/1.0. However,
it was not until the last two years or so that support for this feature was added to most
major web browsers and servers.
4.1 HTTP/1.0
In HTTP/1.0 the manner in which the client and server negotiate which
compression format, if any, to use when transferring a resource is not well defined.
Support for compression exists in HTTP/1.0 by way of content coding values in the
Content- Encoding and, to an extent, the Accept-Encoding header fields.
4.2 HTTP/1.1
HTTP/1.1, provide a way for communicating parties to indicate the type of encoding
transformation that can be, or has been, applied to a resource. The difference being that
transfer coding values are a property of the message and not of the entity. That is,
transfer-coding values can be used to indicate the hop-by-hop encoding that has been
applied to a message [6].
Gzip is an open source, patent free compression utility that was designed
to replace “compress”. Gzip currently uses a variation of the LZ-77 algorithm by default,
though it was designed to handle several compression algorithms [7]. Gzip works by
replacing duplicated patterns with a (distance, length) pointer pair. The distance pointer is
limited to the previous 32 kilobytes while the length is limited to 258 bytes [7].
The identity token indicates the use of default encoding, that is, no
transformation at all.
Chapter 5
5.0 Approaches to HTTP Compression
At first glance, the server level seems like a logical place to perform
HTTP compression. After all, servers have already implemented the HTTP protocol and
know how to communicate with clients and handle retransmits, chunking, HTTP/1.0,
HTTP/1.1, and more. But a Web server is not the best-performing piece of equipment in
the network.
operations of load balancing and doing full HTTP protocol work. In response, they have
offered standalone caching devices rather than attempting to integrate caching
functionality into the load balancer.
Chapter 6
6.0 Browser Support for Compression
Support for content coding is inherent in most of today’s popular web
browsers. Support for content coding has existed in the following browsers since the
indicated version: Netscape 4.5+ (including Netscape 6), all versions of Mozilla, Internet
Explorer 4.0+, Opera 4.0+ and Lynx 2.8+. However, there have been reports that Internet
Explorer for the Macintosh cannot correctly handle gzip encoded content. Unfortunately,
support for transfer coding is lacking in most browsers.
For this test we used all of the web browsers that were accessible to us in
order to see exactly what HTTP request headers these browsers were sending. The header
fields and values that is of greatest interest include the HTTP version number and the
Accept-Encoding and TE field.
GET / HTTP/1.0
Accept-Encoding: gzip, compress
Next, Opera, Netscape and Internet Explorer were tested under various versions
Of Windows. The Opera 5.11 request header contained the following relevant fields:
GET / HTTP/1.1
Accept-Encoding: deflate, gzip, x-gzip, identity,
*;q=0
Connection: Keep-Alive, TE
TE: deflate, gzip, chunked, identity, trailers.
Internet Explorer 5.01, 5.5 SP2 and 6.0 all issued the same relevant
request information:
GET / HTTP/1.1
Accept-Encoding: gzip, deflate
Finally, the Netscape 4.78 request header contained the following relevant
fields:
GET / HTTP/1.0
Accept-Encoding: gzip
GET / HTTP/1.1
Notice that gzip is the most common content coding value and, in fact, the
only value to appear in the request header of every browser tested. Also, observe that
Lynx and Netscape 4.x only support the HTTP/1.0 protocol. For reasons that will be
explained later, some compression-enabled servers may choose not to send compressed
content to such clients. Finally, note that Opera appears to be the only browser that
supports transfer coding as it is the only one that includes the TE header with each HTTP
request.
Chapter 7
7.0 Client Side Compression Issues
When receiving compressed data in either the gzip or deflate format most
web browsers are capable of performing streaming decompression. That is,
decompression can be performed as each successive packet arrives at the client end rather
than having to wait for the entire resource to be retrieved before performing the
decompression [8].
This is possible in the case of gzip because, as was mentioned above, gzip
performs compression by replacing previously encountered phrases with pointers. Thus,
each successive packet the client receives could only contain pointers to phrases in the
current or previous packets, not future packets.
The CPU time necessary for the client to uncompress data is minimal and
usually takes only a fraction of the time it does to compress the data. Thus the
decompression process adds only a small amount of latency on the client’s end.
A test was conducted to verify that some of the major web browsers do in
fact perform streaming decompression. To begin, a single web page consisting of an
extremely large amount of text was constructed. Along with the text, four embedded
images were included. Three of the images were placed near the top of the web page and
the fourth at bottom. The web page was designed to be as simple as possible consisting
only of a few basic HTML tags and image references. The page, which was uploaded to a
compression enabled web server, ended up containing over 550 kilobytes of text.
Three popular web browsers, Opera 5.11, Netscape 4.78 and Internet
Explorer 5.01, all running in Windows 2000, were each used to issue an HTTP request
for the web page. Using Ethereal, a packet-sniffing program, an analysis of the packet log
for each of the three browsers was performed. In all three cases, the browsers, after
receiving a few dozen packets containing the compressed HTML file, issued requests for
the first three embedded image files. Clearly, these requests were issued well before the
entire compressed HTML file had been transferred hence proving that the major
browsers, running in Windows, do indeed perform streaming decompression for content
encoding using gzip.
Chapter 8
8.0 Web Server Support for Compression
The analyses in this report focus exclusively on the two most popular web
servers, namely Apache and IIS. Based on a survey of over 38 million web sites, Netcraft
reported that Apache and IIS comprise over 85% of the hosts on the World Wide Web as
of March 2002. Two alternate web servers, Flash and TUX, were also initially considered
for inclusion in this report, however, based on the information provided in their
respective specification documents, Flash do not appear to support HTTP compression in
any form and TUX can only serve static resources that exist as a precompressed file on
the web server. As a result, neither program was selected for further analysis.
8.1 IIS
Microsoft’s Internet Information Services (IIS) 5.0 web servers provides
built in support for compression; however it is not enabled by default. The process of
enabling compression is straightforward and involves changing a single configuration
setting in IIS. An IIS server can be configured to compress both static and dynamic
documents. However, compression must be applied to the entire server and cannot be
activated on a directory-by directory basis. IIS has built in support for the gzip and
deflate compression standards and includes a mechanism through which customized
compression filters can be added. Also, only the Server families of the Windows
operating system have compression capability, as the Professional family is intended for
use as a development platform and not as a production server...
In IIS, static content is compressed in two passes. The first time a static
document is requested it is sent uncompressed to the client and also added to a
compression queue where a background process will compress the file and store it in a
temporary directory. Then, on subsequent accesses, the compressed file can be retrieved
from this temporary directory and sent to the client.
8.2 Apache
loaded as an external Apache module or compiled directly into the Apache web server.
Since mod_gzip is a standard Apache module, it runs on any platform supported by the
Apache server. Much like IIS, mod_gzip uses existing content-coding standards as
described in HTTP/1.1. Contrary to IIS, mod_gzip allows for compression to be activated
on a per-directory basis thus giving the website administrator greater control over the
compression functionality for his/her site(s). Mod_gzip, like IIS, can compress both static
and dynamic documents.
Chapter 9
9.0 Proxy Support for Compression
Currently one of the main problems with HTTP compression is the lack of
proxy cache support. Many proxies cannot handle the Content-Encoding header and
hence simply forward the response to the client without caching the resource. As was
mentioned above, IIS attempts to ensure compressed documents are not served stale by
setting the Expires time in the past.
This problem was addressed in HTTP/1.1 with the inclusion of the Vary
response header. A cache could then store both a compressed and uncompressed version
of the same object and use the Vary header to distinguish between the two. The Vary
header is used to indicate which response headers should be analyzed in order to
determine the appropriate variant of the cached resource to return to the client.
Looking ahead to Figure 11, we can see that IIS already sends the Vary
header with its compressed content. The most recent version of mod_gzip does not set the
Vary header. However, a patch was posted on a mod_gzip discussion board in April 2001
that incorporates support for the Vary header into mod_gzip. A message posted in
September 2001 was posted to another discussion and stated that mod_gzip had been
ported to Apache 2.0 and includes support for the Vary header.
Based on a quick search of the Web, the latest stable release of Squid,
version 2.4, was the only proxy cache that appeared to support the Vary header. Since
such support was only recently included in Squid it is likely that many proxy caches are
not running this latest version and hence cannot cache negotiated content. Hence the full
potential of HTTP compression cannot be realized until more proxies are able to cache
compressed content.
Chapter 10
10.0 Related Work
In Mogul et al. quantified the potential benefits of delta encoding and data
compression for HTTP by analyzing lives traces from Digital Equipment Corporation
(DEC) and an AT&T Research Lab. The traces were filtered in an attempt to remove
requests for precompressed content; for example, references to GIF, JPEG and MPEG
files. The authors then estimated the time and byte savings that could have been achieved
had the HTTP responses to the clients been delta encoded and/or compressed. The
authors determined that in the case of the DEC trace, of the 2465 MB of data analyzed,
965 MB, or approximately 39%, could have been saved had the content been gzip
compressed. For the AT&T trace, 1054MB, or approximately 17%, of the total 6216 MB
of data could have been saved. Furthermore, retrieval times could have been reduced
22% and 14% in the DEC and AT&T traces, respectively. The authors remarked that they
felt their results demonstrated a significant potential improvement in response size and
response delay as a result of delta encoding and compression.
network environments were used to perform the test: a Local Area Network (high
bandwidth, low latency), a Wide Area Network (high bandwidth, high latency) and a 28.8
kbps modem (low bandwidth, high latency). The test involved measuring the time
required for the client to retrieve the Microscape web page from the server, parse, and, if
necessary, decompress the HTML file on-the-fly and retrieve the 42 inline images. The
results showed significant improvements for those clients on low bandwidth and/or high
latency connections. In fact, looking at the results from all of the test environments,
compression reduced the total number of packets transferred by 16% and the download
time for the first time retrieval of the page by 12%.
11.0 Experiments
We will now analyze the results from a number of tests that were
performed in order to determine the potential benefits and drawbacks of HTTP
compression.
The steps involved in carrying out this test consisted of first fetching the
web page containing the list of Top 99 web sites. This HTML file was then parsed in
order to extract all of the URLs for the Top 99 sites. A pre-existing CGI program on the
Web that allows a user to submit a URL for analysis was then utilized. The program
determines whether or not the indicated site utilizes gzip compression and, if not, how
many bytes could have been saved was the site to implement compression. These byte
savings are calculated for all 10 levels of gzip encoding. Level 0 corresponds to no gzip
encoding. Level 1 encoding uses the least aggressive form of phrase matching but is also
the fastest, as it uses the least amount of CPU time when compared to the other levels,
excluding level 0. Alternatively, level 9 encoding performs the most aggressive form of
pattern matching but also takes the longest, utilizing the most CPU resources.
A Perl script was employed to parse the HTML file returned by this CGI
program, with all of the relevant information being dumped to a file that could be easily
imported into a spreadsheet. Unfortunately, the CGI program can only determine the byte
savings for the HTML file. While this information is useful it does not give the user an
idea of the compression ratio for the entire page - including the images and other
embedded resources. Therefore, we set our web browser to go through a proxy cache and
subsequently retrieved each of the top 99 web pages. We then used the trace log from the
proxy to determine the total size of all of the web pages. After filtering out the web sites
that could not be handled by the CGI program, wget or Perl scripts we were left with 77
URLs. One of the problems encountered by the CGI program and wget involved the
handling of server redirection replies. Also, a number of the URLs referenced sites that
either no longer existed or were inaccessible at the time the tests were run.
The results show that the average total compression ratio comes to about
27% for level 1 encoding and 29% for level 9 encoding. This still represents a significant
amount of savings, especially in the case where the content is being served to a modem
user.
Figure 11.1 – The total page size (including HTML and embedded resources) for
the top ten web sites.
Figure 11.1 shows the difference in the total number of bytes transferred
in an uncompressed web page versus those transferred with level 1 and level 9 gzip
compressions. Note the small difference in compression ratios between level 1 and level
9 encoding.
Table 11.1 shows a comparison of the total compression ratios for the top
ten web sites. You can see that there is only a slight difference in the total compression
ratios for levels 1 and 9 of gzip encoding. Thus, if a site administrator were to decide to
enable gzip compression on a web server but wanted to devote the least amount of CPU
cycles as possible to the compression process, he/she could set the encoding to level 1
and still maintain favorable byte savings.
Table 11.1 – Comparison of the total compression ratios of level 1 and level 9 gzip encoding for
the indicated URLs.
The tests were designed to determine the maximum throughput of the two
servers by issuing a series of requests for compressed and uncompressed documents.
Using Autobench we were able to start by issuing a low rate of requests per second to the
server and then increase this rate by a specified step until a high rate of requests per
second were attempted to be issued. An example of the command line options used to run
some of the tests is as follows:
./autobench_gzip_on --low_rate 10 --
high_rate 150 --rate_step 10 --
single_host --host1 192.168.0.106 --
num_conn 1000 --num_call 1 --output_fmt
csv --quiet --timeout 10 --uri1
/google.html --file google_compr.csv
These command line options indicate that initially requests for the
google.html file will be issued at a rate of 10 requests per second. Requests will continue
at this rate until 1000 connections have been made. For these tests each connection makes
only one call. In other words no persistent connections were used. The rate of requests is
then increased by the rate step, which is 10. So, now 20 requests will be attempted per
second until 1000 connections have been made. This will continue until a rate of 150
requests per second is attempted.
Keep in mind when looking at the results that the client may not be
capable of issuing 150 requests per second to the server. Thus a distinction is made
between the desired and actual number of requests per second.
We will first take a look at the results of the tests when run against the
Apache server. Figures 2 through 5 represent graphs of some of the results from
respective test cases. Referring to the graphs, we can see that for each test case a
saturation point was reached. This saturation point reflects the maximum numbers of
requests the server could handle for the given resource. Looking at the graphs, the
saturation point can be recognized by the point at which the server’s average response
time increases significantly, often times jumping from a few milliseconds up to hundreds
or thousands of milliseconds. The response time corresponds to the time between when
the client sends the first byte of the request and receives the first byte of the reply.
So, if we were to look at Yahoo (Figure 3), for instance, we would notice
that the server reaches its saturation point at about the time when the client issues 36
requests per second for uncompressed content. This figure falls slightly, to about 33
requests per second, when compressed content is requested.
Figure11. 2 – Benchmarking results for the retrieval of the Google HTML file from the Apache
Server.
Figure11. 3 – Benchmarking results for the retrieval of the Yahoo HTML file from the Apache
Server.
Figure 11.4 – Benchmarking results for the retrieval of the AOL HTML file from the Apache
Server.
Figure 11.5 – Benchmarking results for the retrieval of the eBay HTML file from the Apache
Server.
After the saturation point the numbers diverge slightly, as is noticeable in
the graphs. What this means is that the server was able to serve almost the same number
of requests per second for both compressed and uncompressed documents.
For these tests all such bounds were disabled, which caused all resources
to be compressed regardless of their size.
When calculating results we will only look at those cases where the
demanded number of requests per second is less than or equal to the saturation point. Not
surprisingly, compression greatly reduced the network bandwidth required for server
replies. The factor by which network bandwidth was reduced roughly corresponds to the
compression ratio of the document.
Table11. 2 – Estimated saturation points for the Apache web server based on repeated
client requests for the indicated document
Table 11.3 – Average response time (in milliseconds) for the Apache server to respond to
requests for compressed and uncompressed static documents.
Figure 11.6 – Benchmarking results for the retrieval of the Google HTML file from the IIS
Server.
Figure 11.7 – Benchmarking results for the retrieval of the Yahoo HTML file from the IIS Server.
Figure 11.8 – Benchmarking results for the retrieval of the AOL HTML file from the IIS Server.
Figure 11.9 – Benchmarking results for the retrieval of the eBay HTML file from the IIS Server.
However, as we can see in Figure 11.9, when a client requests an ASP file
in compressed form, IIS appears to send the compressed content to the client in chunks.
Thus, the server can immediately compress and send chunks of data as they are
dynamically generated without having to wait for the entire document to be generated
before performing this process. Such a process appears to significantly reduce response
time latency. In this way IIS is able to achieve average response times that are identical to
the response times for uncompressed content.
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 11 Dec 2001 18:01:09 GMT
Connection: close
Content-Length: 13506
Content-Type: text/html
Set-Cookie:
ASPSESSIONIDGGQQQJHK=EJKABPBDEDGHBPLPLMDP
EAHA; path=/
Cache-control: private
Figure 11.10 – HTTP response header from an IIS Server after a request for an uncompressed .asp resource
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.0
Date: Tue, 11 Dec 2001 18:01:01 GMT
Connection: close
Content-Type: text/html
Set-Cookie:
ASPSESSIONIDGGQQQJHK=DJKABPBDPEAMPJHEBNIH
CBHB; path=/
Content-Encoding: gzip
Transfer-Encoding: chunked
Expires: Wed, 01 Jan 1997 12:00:00 GMT
Cache-Control: private, max-age=86400
Vary: Accept-Encoding
Figure 11.11 – HTTP response header from an IIS Server after a request for a compressed .asp
resource
The graphs show that the lines for the average response times follow
nearly identical paths for the Google, Yahoo! and AOL test case, though there is a slight
divergence in the AOL test as you near the saturation point. In the eBay test, however,
the server achieves must quicker average response times. Again, this can be explained by
the server’s use of chunked transfers. Looking at the graphs we can see that for the
Google, Yahoo! and AOL test cases, the saturation point is roughly equivalent regardless
of whether the content is served in a compressed form or not.
Based on these results we conclude that the use of chunked transfer coding
for compressing dynamic content provides significant performance benefits.
Chapter 12
12.0 Summary / Suggestion
So, should a web server use HTTP compression? Well, that’s not such an
easy question to answer. There are a number of things that must first be considered. For
instance, if the server generates a large amount of dynamic content one must consider
whether the server can handle the additional processing costs of on-the-fly compression
while still maintaining acceptable performance. Thus it must be determined whether the
price of a few extra CPU cycles per request is an acceptable trade-off for reduced
network bandwidth. Also, compression currently comes at the price of cache ability.
First, the design of a new patent free algorithm that is tailored specifically
towards compressing web documents, such as HTML and CSS, could be helpful. After
all, gzip and deflate are simply general purpose compression schemes and do not take
into account the content type of the input stream. Therefore, an algorithm that, for
instance, has a predefined library of common HTML tags could provide a much higher
compression ratio than gzip or deflate.
Until these issues can be resolved HTTP compression will likely continue
to be overlooked as a way to reduce user perceived latency and improve Web
performance.
References
1 http://www.http-compression.com
2 http://www.google.com
6 http://www.ietf.org/rfc/rfc2616.txt
7 http://www.gzip.org/zlib/feldspar.html.