Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống
1
/ 219 trang
THÔNG TIN TÀI LIỆU
Thông tin cơ bản
Định dạng
Số trang
219
Dung lượng
1,75 MB
Nội dung
Web PerformanceTuning
Patrick Killelea
First Edition, October 1998
ISBN: 1-56592-379-0, 374 pages
Web PerformanceTuning hits the ground running and gives concrete advice for improving
crippled Webperformance right away.
For anyone who has waited too long for a Web page to display or watched servers slow to a
crawl, this book includes tips on tuning the server software, operating system, network, and
the Web browser itself.
Release Team[oR] 2001
CONTENTS
Preface 1
What Is This Book Good For?
Audience for This Book
Assumptions of This Book
How This Book Is Organized
Font Conventions
How to Contact Us
Web Site Updates and Code Examples
Other Books and Resources
Disclaimer
Acknowledgments
Preliminary Considerations 10
1 The Blunt Instruments 11
Improving Performance from the Browser Side
Improving Performance from the Server Side
Key Recommendations
2 Capacity Planning 17
Capacity Planning Is Preemptive PerformanceTuning
Methodology
Questions to Ask
How Much Bandwidth Do You Need?
How Fast a Server Do You Need?
How Much Memory Do You Need?
Architecture Scaling Options
Key Recommendations
3 WebPerformance Measurement 35
Parameters of Performance
Benchmark Specifications and Benchmark Tests
WebPerformance Measuring Tools and Services
Key Recommendations
4 Case Studies 45
Example Performance Problems, Diagnoses, and Solutions
Methodology for Performance Consulting
Sample Configurations
Key Recommendation
5 Principles and Patterns 51
Principles of PerformanceTuning
Patterns of Performance Improvement
Key Recommendations
Tuning in Depth 58
6 Client Software 59
Brief History of the Web Browser
How Browsers Work
Popular Browsers
Browser Speed
Browser Tuning Tips
Figuring Out Why the Browser Is Hanging
Key Recommendations
7 Client Operating System 67
Macintosh
Microsoft Windows
Unix
Key Recommendations
8 Client Hardware 71
PC Hardware
Key Recommendations
9 Network Hardware 77
Lines and Terminators
Intranets
Network Modeling Tools
The Internet
PTTs
Key Recommendations
10 Network Protocols 94
Power and Protocols
The Protocols of the Web
Key Recommendations
11 Server Hardware 109
How Server Hardware Is Different
Network Interface Card
Bus
Memory
CPU
Disk
Key Recommendations
12 Server Operating System 117
Unix and the Origin of the Web
Unix Flavors
Processes and the Kernel
The Filesystem
The Windowing System
Versions and Patches
Configurable OS Parameters
Unix OS Monitoring Tools
Unix Versus NT as the Web Server OS
Key Recommendations
13 Server Software 131
Inside Web Server Software
Common Server Parameters
Servers
Proxy Servers
Firewalls
Key Recommendations
14 Content 140
Size Matters
HTML
Graphics
Audio
Video
Key Recommendations
15 CGI Programs 145
CGI Internals and Performance Problems
General CGI Tips
CGI Language-Specific Optimization Tips
Daemonize It
CGI Database Access Performance
Key Recommendations
16 Java 156
What Java Does for You
Java Compared to Native Code
Why It's Getting Better
Performance Tips: What You Can Do
Key Recommendations
17 Databases 165
Do You Really Need a Relational Database?
Performance Tips
Key Recommendations
Appendixes 168
A Netscape Enterprise Server 3.0 Tuning 169
Introduction
Audience
What Is perfdump?
Installing perfdump
Using perfdump Statistics
Platform-Specific Issues
Benchmarking the Netscape Enterprise Server
B Apache Performance Notes 180
Introduction
Hardware and Operating System Issues
Runtime Configuration Issues
Negotiation
Process Creation
Compile-Time Configuration Issues
Detailed Analysis of a Trace
The Preforking Model
C Solaris 2.x -Tuning Your TCP/IP Stack and More 190
Please Share Your Knowledge
History and Introduction
TCP Connection Initiation
Retransmission-Related Parameters
Path MTU Discovery
Further Advice, Hints, and Remarks
Windows, Buffers, and Watermarks
Tuning Your System
Recommended Patches
Related Books and Software
Author's Tips 213
Web PerformanceTuning
For as long as there's been a Web, people have been trying to make it faster. The maturation of the Web has
meant more users, more data, more bells and whistles, and consequently longer waits on the Web. Improved
performance has become one of the most important factors in determining the usability of both the Web in
general and of individual sites in particular.
Web PerformanceTuning is about getting the best performance from the Web. This book isn't just about tuning
the web server software; it's also about getting optimal performance from a browser, tuning the hardware (on
both the server and browser ends), and maximizing the capacity of the network itself.
Web PerformanceTuning hits the ground running, giving concrete advice for quick results the "blunt
instruments" for improving crippled performance right away. The book then takes a breath and pulls back to give
a conceptual background of the principles of computing performance. The latter half of the book approaches each
element of a web transaction from client to network to server to examine the weak links in the chain and how
to strengthen them.
Tips include:
• Using simultaneous downloads to locate bottlenecks
• Adjusting TCP for better webperformance
• Reducing the impact of DNS
• Upgrading device drivers
• Using alternatives to CGI
• Locating the web server strategically
• Minimizing browser cache lookups
• Avoiding symbolic links for web content
Web PerformanceTuning
p
age 1
Preface
When I told people I was writing a book called WebPerformance Tuning, the usual response I got was that the
title should be "Web Server Performance Tuning." Most people believe that the server is the only part of the
Web that you can tune. When you're desperate to improve performance, however, you become much more
creative about finding other parts of the Web that you can tune. You may not be able to do much about the
public network or about remote clients, but you can tune entire intranet systems, including clients, networks,
servers, and databases, and you can improve your access to the public network through better connections and
strategic locations for clients and servers. Yes, you can tune the web server itself, but the server is only one
piece.
Thinking in terms of individual machines is rapidly becoming obsolete. An isolated machine, whether PC or
mainframe, is increasingly rare. There is a very good reason for this: a collection of machines is far more
powerful, flexible, and reliable than any individual machine. The network takes on the characteristics of a bus
connecting the components of a larger and better computer. To have a network connection to another machine
is to have more power available from your own machine. To be connected to the Internet is to have access to
millions of machines. The biggest disk in the world is simply all disks wired together.
What Is This Book Good For?
This book is good for improving web site performance, estimating web site hardware and software
requirements, and clarifying scaling issues. It covers client and network issues as well as server-side issues,
because many web sites are on intranets, where a system administrator has control over the client and
network. While most webperformance discussion centers on the HTTP server, the HTTP server itself is not
usually the performance bottleneck. To improve performance, we must also look at other issues.
The performance I care about is from the end user's point of view: how quickly the Web satisfies the user's
request. There are other kinds of performance, such as total server throughput or availability, but this book
focuses on the user's perception of speed.
Although it presents some general principles of performance tuning, this book concentrates on practical advice
much more than on theory. The principles are presented only to show patterns that unify typical web
performance problems and solutions. While any book on performancetuning is to some degree a collection of
tips and tricks, I hope the principles help to bring some order to this collection.
Another goal of this book is to present a clear picture of the chain of events involved in viewing a web page.
Having a clear mental model of exactly what happens and why is critical to reasoning through new performance
problems and finding solutions.
In the end, performancetuning is about spending money and time wisely to get the most out of your resources.
A lot of life is like that.
Audience for This Book
Web PerformanceTuning will be of interest to anyone responsible for a web site, from the person running a
personal site off a Linux PC at home up to large corporate sites with multiple enterprise-class servers and
redundant Internet connections. The book assumes you are familiar with the fundamentals of setting up a web
site and getting connected to the Internet. If you need advice on setting up a web site, see Apache: The
Definitive Guide, by Ben Laurie and Peter Laurie (O'Reilly & Associates). If you need advice on how to get
connected to the Internet, see Getting Connected, by Kevin Dowd (O'Reilly & Associates).
This is a book of practical advice on the configuration and application-level programming of commodity
components, not a book for operating system programmers, compiler writers, or chip designers. In other words,
the book goes over what you can change right now from the system administration and application level.
To some degree, you are at the mercy of the market to supply you with good building blocks. Since the
performance of a web site is a function not only of the tuning parameters and options but also of the raw
hardware and software products involved, this book also includes information on how to select the appropriate
products. The issues of scalability and conformance with open standards will also be covered.
Web PerformanceTuning
p
age 2
Here are some representative titles of people who might have an interest in this book:
• System Administrator
• System Architect
• System Integrator
• Web Applications Programmer
• Web Content Developer
• Webmaster
Assumptions of This Book
This book assumes a basic familiarity with the technical components of the Web. Throughout the book, there are
descriptions of the events that occur in a typical HTTP operation. There are also references in the text and the
appendixes to other books and web sites for those who need more background or want to explore a subject in
more depth.
The server examples are drawn from the Unix world because a majority of web servers use the Unix operating
system, and because Unix has proven suited to running a scalable high-performance web site. To be completely
honest, it's also because my experience has been mostly with Solaris and Linux, and I like them. If you use a
non-Unix web server, you'll find that most of the advice in this book is still applicable to your server, but the
specific details will vary.
It is assumed that the reader has some programming experience with C, Java™, or Perl, but that is not a
requirement for using this book.
How This Book Is Organized
The first part of this book goes over topics of general interest to anyone running a web site, including quick and
simple performance boosts, estimating what hardware and software you need for a given load and level of
performance, common measures of web site performance, case studies of some web sites, and principles of
performance tuning.
The structure of the second part of book is modeled on what actually happens when the user of a web browser
requests an HTML page from a web server. We'll follow an HTML request from client to network to server to CGI
to database (see Preface). We'll also cover what happens when a Java applet is downloaded from the server and
started in the browser. From the browser's point of view, after the request is sent, the answer magically
appears on the network. From the network's point of view, the answer magically appears at the connection to
the server, and so on. We'll trace the process back one stage at a time to point out performance issues along
the way and to eliminate the unknown. We'll also give tips for finding out which side of each interface is slower
so that you can figure out where the bottleneck is and how to bring the performance of that section into line
with the rest of your web site.
Web PerformanceTuning
p
age 3
1.1. The chain of events
Web PerformanceTuning
p
age 4
Part I
Chapter 1, describes crude but often effective measures to increase your site's performance when you
just don't have time to analyze your system and tune it the "right" way.
Chapter 2, helps you make decisions about what kind of hardware and software you'll need to allow your
site to perform well and scale for the future.
Chapter 3, describes webperformance benchmarks and why they may be unreliable indicators of real-
world performance.
Chapter 4, gives some examples of performance problems and solutions, and describes major
commercial web sites, including what hardware and software they use.
Chapter 5, describes some general principles to keep in mind when thinking about the performance of
your web site.
Part II
Chapter 6, tells you what's going on in your browser and how to help it along, especially when it seems
to be hanging.
Chapter 7, gives tips on the differences between the various OSs and how these affect browser
performance.
Chapter 8, describes what the bottlenecks are on the client hardware and what you can do about them.
Chapter 9, describes the hardware of the Internet. There's not a lot you can do about hardware that
belongs to someone else, but you can at least influence the parts of the Internet you use. If you're
running your own intranet, you can modify many parameters to tune performance.
Chapter 10, describes the protocols at the core of the Web and gives you tips on how the protocols
interact and how to get them to play nicely together.
Chapter 11, describes issues constraining the server, such as disk bottlenecks.
Chapter 12, gives tuning hints for the typical Unix web server.
Chapter 13, discusses the free and commercial HTTP server software available.
Chapter 14, goes over the various kinds of data you return to the user and the performance implications
of each.
Chapter 15, gives you tips and tricks for reducing the amount of time spent in CGI processes.
Chapter 16, goes over some issues in optimizing your Java applications.
Chapter 17, describes the performance and cost of various database systems.
Part III
Appendix A, contains Netscape's own advice for tuning their web server.
Appendix B, written by one of the authors of Apache, discusses performance issues for the Apache web
server.
Appendix C, gives detailed Solaris TCP advice from Jens-S. Vöckler.
[...]... http://www.nlanr.net/Papers/data-inet97.html Excellent review of the state of performance measurement of the Internet http://www.rational.com/ Includes some papers on application performancetuning http://www.sun.com/workshop/java/wp-javaio/ http://www.sun.com/solaris/java/wp-java/ Information about running Java quickly on Solaris 2.6 http://www.sun.com/sunworldonline/swol-0 3-1 996/swol-03-perf.html Good web server performance. .. server performance article http://www.sgi.com/Technology /web/ SGI's Web Performance Tuning Guide page 7 WebPerformanceTuning http://www.techweb.com/speed/ Lots of tuning tips, but only for Windows platforms http://www.cerberus-sys.com/~belleisl/mtu_mss_rwin.html The definitive site for Winsock tuning http://www.w3.org/ Has the RFCs on which the web is based http://www.sun.com/javastation/whitepapers/serversizingguide/... writing to: O'Reilly & Associates 101 Morris Street Sebastopol, CA 95472 1-8 0 0-9 9 8-9 938 (in the U.S or Canada) 1-7 0 7-8 2 9-0 515 (international/local) 1-7 0 7-8 2 9-0 104 (FAX) You can also send messages electronically To be put on our mailing list or to request a catalog, send email to: info@oreilly.com To ask technical questions or to comment on the book, send email to: bookquestions@oreilly.com We have a web site... Perl (O'Reilly & Associates, 1996) 25 Wong, Brian L., Configuration and Capacity Planning for Solaris Servers (Prentice Hall, 1997) See especially Chapter 4, on configuring web services 26 Wong, Clinton, Web Client Programming with Perl (O'Reilly & Associates, 1997) page 6 WebPerformanceTuningWeb Sites with Performance Information http://help.netscape.com/kb/server/97121 1-7 .html The Netscape tuning. .. database queries page 16 WebPerformanceTuning Chapter 2 Capacity Planning 2.1 Capacity Planning Is Preemptive PerformanceTuning Since this is a book on webperformance tuning, you might think a chapter on capacity planning is out of place Not so Capacity planning and performancetuning are in a sense the same thing: choosing system components, placement, and parameters based on performance criteria... Wide Web (O'Reilly & Associates, 1996) 12 Gurry, Mark and Peter Corrigan, Oracle PerformanceTuning (O'Reilly & Associates, 1996) 13 Harold, Elliotte Rusty, Java Network Programming (O'Reilly & Associates, 1997) 14 Laurie, Ben and Peter Laurie, Apache: The Definitive Guide (O'Reilly & Associates, 1997) 15 Libes, Don, Exploring Expect (O'Reilly & Associates, 1994) 16 Loukides, Mike, System Performance Tuning. .. networking- and performance- related patches page 15 WebPerformanceTuning Dedicate your web server Don't run anything unnecessary for web service on your web server In particular, your web server should not be an NFS server, an NNTP server, a mail server, or a DNS server Find those things other homes Kill all unnecessary daemons, such as lpd Don't even run a windowing system on your web server You don't... plans for future editions You can access this page at: http://www.oreilly.com/catalog/webpt/ For more information about this book and others, see the O'Reillyweb site: http://www.oreilly.com The author can be reached at: webperf@patrick.net page 5 WebPerformanceTuningWeb Site Updates and Code Examples Be warned that web pages frequently change without regard to references to them For the latest corrections... 10000-byte web hits in one day, evenly distributed 0.925925 106 hits/day × 80Kbits/hit × day/86400 seconds × M/106 Audio CD 1.280000 40000 samples/second × 16 bits/sample × 2 (stereo) × M/106 T-1 (DS-1 or primary ISDN) 1.544000 Carries 24 POTS channels with 8kbps overhead Ethernet 10.00000 Token Ring 16.00000 IDE Hard disk 16.00000 Sustained throughput T-3 (DS-3) 44.60000 672 DS-0's, 28 DS-1's, or 7 DS-2's... file page 20 WebPerformanceTuning Those headers look like this: HTTP/1.0 200 Document follows Date: Sat, 30 Aug 1997 04:31:18 GMT Server: NCSA/1.4.2 Content-type: text/html Last-modified: Mon, 16 Dec 1996 04:51:12 GMT Content-length: 217 This header itself is 174 bytes, which is 45% of your server's output in this case Header size has been creeping up as more capabilities are added to web servers . http://www.sgi.com/Technology /web/ SGI's Web Performance Tuning Guide. Web Performance Tuning p age 8 http://www.techweb.com/speed/ Lots of tuning tips, but only for Windows platforms. http://www.cerberus-sys.com/~belleisl/mtu_mss_rwin.html. Associates 101 Morris Street Sebastopol, CA 95472 1-8 0 0-9 9 8-9 938 (in the U.S. or Canada) 1-7 0 7-8 2 9-0 515 (international/local) 1-7 0 7-8 2 9-0 104 (FAX) You can also send messages electronically Web Performance Tuning Patrick Killelea First Edition, October 1998 ISBN: 1-5 659 2-3 7 9-0 , 374 pages Web Performance Tuning hits the ground running and