ebook img

Using WebPagetest: Web Performance Testing for Novices and Power Users PDF

199 Pages·2014·6.198 MB·English
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Using WebPagetest: Web Performance Testing for Novices and Power Users

www.it-ebooks.info Using WebPagetest Rick Viscomi, Andy Davies, and Marcel Duran Boston www.it-ebooks.info Using WebPagetest by Rick Viscomi, Andy Davies, and Marcel Duran Copyright © 2010 Rick Viscomi, Andy Davies and Marcel Duran. All rights reserved. Printed in the United States of America. Published by O’Reilly Media, Inc., 1005 Gravenstein Highway North, Sebastopol, CA 95472. O’Reilly books may be purchased for educational, business, or sales promotional use. Online editions are also available for most titles (http://my.safaribooksonline.com). For more information, contact our corporate/ institutional sales department: 800-998-9938 or [email protected]. Editors: Courtney Nash and Brian Anderson Indexer: FIX ME! Production Editor: FIX ME! Cover Designer: Karen Montgomery Copyeditor: FIX ME! Interior Designer: David Futato Proofreader: FIX ME! Illustrator: Rebecca Demarest December 2014: First Edition Revision History for the First Edition: 2014-06-24: Early release revision 1 2014-07-29: Early release revision 2 2014-09-15: Early release revision 3 2014-10-17: Early release revision 4 2015-02-02: Early release revision 5 2015-04-07: Early release revision 6 2015-07-29: Early release revision 7 See http://oreilly.com/catalog/errata.csp?isbn=9781491902592 for release details. Nutshell Handbook, the Nutshell Handbook logo, and the O’Reilly logo are registered trademarks of O’Reilly Media, Inc. !!FILL THIS IN!! and related trade dress are trademarks of O’Reilly Media, Inc. Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and O’Reilly Media, Inc. was aware of a trademark claim, the designations have been printed in caps or initial caps. While every precaution has been taken in the preparation of this book, the publisher and authors assume no responsibility for errors or omissions, or for damages resulting from the use of the information contained herein. ISBN: 978-1-491-90259-2 [?] www.it-ebooks.info Table of Contents Preface. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . vii Part I. Basic Use Cases 1. “How fast is my page?”. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3 Measure What Matters 3 Synthetic vs RUM 4 2. “What is slowing down my page?”. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Running a Simple Test 7 Reading a Waterfall 12 Waterfall Slope 18 Connection View 21 Common Antipatterns 22 WebPagetest Grades 27 First Byte Time 28 Keep-Alive Enabled 29 Compress Transfer 30 Compress Images 30 Progressive JPEGs 30 Cache Static Content 31 Effective Use of CDN 31 3. Cache Optimization. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 Enabling Repeat View 34 Analyzing Cachability 36 Heuristic Caching 37 iii www.it-ebooks.info 4. Comparing Tests. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41 Perceived Performance 41 Capture Video 42 Filmstrip and Video 43 Speed Index 48 Summary 52 Part II. Intermediate Use Cases 5. Simulating Real Users. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Identifying Demographics 58 Popular Pages 61 Device and Browser 62 Geographic Location 66 Connection Speed 69 6. Mobile Testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 75 Desktop Emulation 75 Traffic Shaping 79 Native Devices 80 7. Scripting Preconditions. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Flow View 84 logData and navigate 85 Authentication 86 HTTP Basic Authentication 87 DOM Manipulation 88 Setting Cookies 89 8. SPOF Testing. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 91 Blackhole Rerouting 93 setDns 94 SPOF Tab 96 Blocking Requests 98 Part III. Advanced Use Cases 9. API. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103 Getting started 103 Requesting a key 103 Running tests 105 iv | Table of Contents www.it-ebooks.info Simple example test 105 Advanced example test 107 Reading results 108 Polling test results 110 Pingback test results 111 Reading beyond results 112 10. Continuous Integration. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 113 Node.js wrapper 113 Installing WebPagetest Node.js wrapper 114 Choosing your WebPagetest server 114 Specifying the API Key 115 Running tests and reading results 115 WebPagetest Node.js wrapper extra feature: RESTful Proxy (Listener) 119 Running proxy from Node.js module 120 Asserting metrics from test results 120 JSON test specs 120 Defining assertion comparison 121 Setting default operations and labels 122 Available output text template tags 123 Avaliable assertion operations 123 Overriding labels 123 Specifying test reporter 123 Test Specs examples 124 Jenkins integration 125 Configuring Jenkins 125 Travis-CI integration 126 Configuring Travis-CI 126 11. Tracking Performance over Time. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129 Public vs Private Instance 129 Grunt-WPT 130 ShowSlow 131 Long term trending 131 Logging Results to a File 132 Splunk 132 HTTP Archive 133 12. Private Instances. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 135 How does WebPagetest work? 136 Using the Pre-Configured AWS AMI 137 Create an AWS User with Relevant Permissions 137 Table of Contents | v www.it-ebooks.info Configure and Launch AWS Instance 138 Creating your own local installation 140 Desktop Test Agents 142 Mobile Test Agents 146 Install NodeJS Agent 147 Add test devices 147 Bandwidth shaping 151 Remote Test Agents 152 Private Instance Only Features 153 Bulktest 153 Custom Metrics 155 Day-to-Day Management 155 Monitoring Queues and Test Agents 155 Archiving Old Tests 157 Updating an Instance 158 Troubleshooting 158 Contributing 160 A. Reference guide. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163 Index. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 187 vi | Table of Contents www.it-ebooks.info Preface Who Should Read This Book • independent site owners • web developers • performance engineers Goals of This Book This book will teach beginner users of WebPagetest how to run and analyze tests. It will show intermediate users how to use scripting to create more sophisticated test scenarios, how to integrate it into their everyday processes and finally how to install their own instance of WebPagetest for a controlled testing environment A Word on Web Performance Today We all know bad web performance when we see it. When something takes too long to load or become interactive we start to get bored, impatient, or even angry. The speed of a web page has the ability to evoke negative feelings and actions from us. When we lose interest, wait too long, or get mad, we may not behave as expected: to consume more content, see more advertisements, or purchase more products. The web as a whole is getting measurably slower. Rich media like photos and videos are cheaper to download thanks to faster Internet connections, but they are more prevalent than ever. Expectations of performance are high and the bar is being raised ever higher. By reading this book, chances are you’re not only a user but most importantly someone who can do something about this problem. There are many tools at your disposal that specialize in web performance optimizations. However, none are more venerable than WebPagetest.org. WebPagetest is a free, open source web application that audits the vii www.it-ebooks.info speed of web pages. In this book, we will walk you through using this tool to test the performance of web pages so that you can diagnose the signs of slowness and get your users back on track. Navigating This Book This book is organized into three primary sections: basic, intermediate, and advanced use cases, each of which corresponds to a different level of familiarity with WebPagetest: 1. Basic use cases provide a foundation of testing experience by explaining how to run and interpret simple tests. 2. Intermediate use cases have a deeper focus on more sophisticated test scenarios, some of which may require scripted commands to configure how the tests are ex‐ ecuted. 3. Advanced use cases describe lower-level capabilities typically required by special test environments including the API and private instances. Conventions Used in This Book The following typographical conventions are used in this book: Italic Indicates new terms, URLs, email addresses, filenames, and file extensions. Constant width Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords. Constant width bold Shows commands or other text that should be typed literally by the user. Constant width italic Shows text that should be replaced with user-supplied values or by values deter‐ mined by context. This icon signifies a tip, suggestion, or general note. viii | Preface www.it-ebooks.info This icon indicates a warning or caution. Using Code Examples Supplemental material (code examples, exercises, etc.) is available for download at https://github.com/oreillymedia/title_title. This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of ex‐ ample code from this book into your product’s documentation does require permission. We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Book Title by Some Author (O’Reilly). Copyright 2012 Some Copyright Holder, 978-0-596-xxxx-x.” If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at [email protected]. Safari® Books Online Safari Books Online is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business. Technology professionals, software developers, web designers, and business and crea‐ tive professionals use Safari Books Online as their primary resource for research, prob‐ lem solving, learning, and certification training. Safari Books Online offers a range of product mixes and pricing programs for organi‐ zations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Pro‐ fessional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technol‐ Preface | ix www.it-ebooks.info

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.