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
WebPerformanceTuning Patrick Killelea First Edition, October 1998 ISBN: 1-56592-379-0, 374 pages WebPerformanceTuning 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 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 The Blunt Instruments Improving Performance from the Browser Side Improving Performance from the Server Side Key Recommendations 11 Capacity Planning 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 17 WebPerformance Measurement Parameters of Performance Benchmark Specifications and Benchmark Tests WebPerformance Measuring Tools and Services Key Recommendations 35 Case Studies Example Performance Problems, Diagnoses, and Solutions Methodology for Performance Consulting Sample Configurations Key Recommendation 45 Principles and Patterns Principles of PerformanceTuning Patterns of Performance Improvement Key Recommendations 51 Tuning in Depth 58 Client Software 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 59 Client Operating System Macintosh Microsoft Windows Unix Key Recommendations 67 Client Hardware PC Hardware Key Recommendations 71 Network Hardware Lines and Terminators Intranets Network Modeling Tools The Internet PTTs Key Recommendations 10 Network Protocols Power and Protocols The Protocols of the Web Key Recommendations 77 94 11 Server Hardware How Server Hardware Is Different Network Interface Card Bus Memory CPU Disk Key Recommendations 109 12 Server Operating System 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 117 13 Server Software Inside Web Server Software Common Server Parameters Servers Proxy Servers Firewalls Key Recommendations 131 14 Content Size Matters HTML Graphics Audio Video Key Recommendations 140 15 CGI Programs CGI Internals and Performance Problems General CGI Tips CGI Language-Specific Optimization Tips Daemonize It CGI Database Access Performance Key Recommendations 145 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 Do You Really Need a Relational Database? Performance Tips Key Recommendations 165 Appendixes 168 A Netscape Enterprise Server 3.0 Tuning Introduction Audience What Is perfdump? Installing perfdump Using perfdump Statistics Platform-Specific Issues Benchmarking the Netscape Enterprise Server 169 B Apache Performance Notes Introduction Hardware and Operating System Issues Runtime Configuration Issues Negotiation Process Creation Compile-Time Configuration Issues Detailed Analysis of a Trace The Preforking Model 180 C Solaris 2.x - Tuning Your TCP/IP Stack and More 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 190 Author's Tips 213 WebPerformanceTuning 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 WebPerformanceTuning 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 WebPerformanceTuning 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 WebPerformanceTuning 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 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 webperformance 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 WebPerformanceTuning 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 page WebPerformanceTuning 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 performancetuning 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 page WebPerformanceTuning 1.1 The chain of events page WebPerformanceTuning 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 realworld 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 about them Chapter 9, describes the hardware of the Internet There's not a lot you can 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 page ... http://www.sun.com/sunworldonline/swol-03-1996/swol-03-perf.html Good web server performance article http://www.sgi.com/Technology /web/ SGI's Web Performance Tuning Guide page Web Performance Tuning http://www.techweb.com/speed/ Lots of tuning tips,... links for web content Web Performance Tuning Preface When I told people I was writing a book called Web Performance Tuning, the usual response I got was that the title should be "Web Server Performance. . .Web Performance Tuning Patrick Killelea First Edition, October 1998 ISBN: 1-56592-379-0, 374 pages Web Performance Tuning hits the ground running and gives