Pro PHP Application Performance

所需积分/C币:9 2017-08-20 09:54:21 10.93MB PDF
2
收藏 收藏
举报

Pro PHP Application Performance
Pro PHP Application Performance: Tuning PHP Web Projects for Maximum Performance Copyright o 2010 by Armando Padilla and Tim Hawkins All rights reserved. No part of this work may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, or by any formation storage or retrieval system, without the prior written permission of the copyright owner and the publisher. ISBN-13(pbk):978-1-4302-2898-1 ISBN-13( electronic):978-143022899-8 Printed and bound in the united states of america 987654321 Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the trademark. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights President and Publisher: Paul Manning Lead editor. frank pohlmann Development Editors: Jim Markham and Michelle lowman Technical Reviewer: Aaron Saray Editorial Board: Steve Anglin, Mark Beckner, Ewan Buckingham, Gary Con sound Jonathan Gennick, Jonathan Hassell, Michelle Lowman, Matthew moodie, d Parkes, Jeffrey Pepper, Frank Pohlmann, Douglas Pundick, Ben Renow-Clarke Dominic shakeshaft Matt wade, Tom Welsh Coordinating editor: Jennifer L. Blackwell Copy Editor: Mary Ann Fugate Compositor: MacPS, LLC Indexer: Becky hornyak Artist: April milne Cover Designer: Anna Ishchenko Distributed to the book trade worldwide by Springer Science+Business Media, LLC, 233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax(201)348-4505 e-mailorders-ny@springer-sbm.comorvisitwww.springeronline.com Forinformationontranslationspleasee-mailrightsqapress.comorvisitwww.apress.com Apress and friends of ed books may be purchased in bulk for academic, corporate, or promotional use e Book versions and licenses are also available for most titles. For more information, reference our Special Bulk Sales-e Book licensing web page at www.apress.com/info/bulksales Contents at a glance 一 Contents mmmmrmm. About the authors…a………na,xi about the technical reviewer Acknowledgmentsaat ■■■■■■L■I■■■■■■■■■■■■■■■■■■■■■■■ Introducti0m………,……1Xy Chapter 1: Benchmarking Techniques ametaaateeatesamamenamanatasanna 1 Chapter 2: Improving Client Download and Rendering Performanceammmtmmmmaa 25 Chapter 3: PHP Code Optimization 55 Chapter 4: Opcode caching amat 83 Chapter 5: Variable cachingaao. ■■■a通■■■■■ 109 Chapter 6: Choosing the Right Web server .matmatmeamameammaatm. 131 Chapter 7: Web server and Delivery Optimization ma. 165 Chapter 8: Database Optimization.mmmaamteaan 189 Appendix A: Installing Apache MySQL PHP, and PECl on windows.ns 209 Appendix B: Installing Apache MysQL, PHP, and PECL on Linux tam eam ammam. 227 Index n233 Contents Contents at a glance mmmmmummmmmiy About the authors About the technical reviewer.……i Acknowledgments amaaaammiaaimaIaammIEmIm IMaM XiV Introduction……Xy Chapter 1: Benchmarking Techniques ■面■■面■■■■■■通■■■面■■■■ ■■面■L面■■口 The PhP application Stack 2 Benchmarking Utilities 3 Defining the request/Response lifecycle Apache benchmark Installing Apache Benchmark .mmaaauamasamanasammmaaamaumanamauemma5 RunnIng apache benchmark Making sense of the response AB option Flags aa…10 AB Gotchas 画面1面面面面 15 Siege …15 Installing Siege Running Siege.a. 16 EXamining the Results 面着 Siege option Flags.…… 19 Testing Many URLs….….….....….....:.:::::19 ■ coNtENTS Affecting Your Benchmark Figures..aa.... 20 Geographical Location .. ............. The Traveling Packets Response Size....... Code complexity Browser behavior n画日日日面a面aB 22 Web Server Setup… Summary.se. 24 Chapter 2: Improving client Download and Rendering performance mmmmmtmmmmtmne 25 The Importance of Optimizing Responses 27 Firebug……… 28 Installing Firebug. Firebug Performance Tabs The Console tab. mmmmmmmmmmmmmmmm 30 The net ta 32 YSlow 33 YS|oWv2 Rulesets…34 Installing yslow.... 35 Starting yslow Page speed ...mm.mmmmmm...m..mmm...mmmm...m.mmm..mm...mm.m.n..m..m 39 Installing Page Speed Page Speed at Work Optimization Tools JavaScript Optimization 42 Javascript placement Minification of JavaScript 46 Minification Tools 47 YUI Compressor 47 Closure Compiler. amamammaa ■ CONTENTS Reduce Resource Requests 49 Use Server-Side Compression ................ 49 Image Compression.. 49 Smush. it …150 Summary 52 Chapter 3: PHP Code Optimization m ERBERBRBERERIERRIBERERIRRIRRBR RBEIERRIR REI EI 55 PHP Best Practices 55 The PHP Economy 57 require vs require once..s. 58 Calculating Loop Length in Advance.... Accessing Array Elements Using foreach VS for vs. while ... File Access 164 - aster Access to object Proper Looking Under the Hood Using VLD, strace, and Xdebug. aaaaaa. 68 Reviewing Opcode Functions with VLD Using strace for C-level Tracing…… Identifying Bottlenecks 73 Xdebug 2: PHP Debugging TooL...... Validating Installation 37 Installing the gUl-Based Tool................. Summary...,.,..,…,80 Chapter 4: Opcode caching sS B IRBSESaIB BR B RIRIRRISISmIB SImIIaImmB 83 Reviewing Our Roadmap …83 The PhP Life Cycle 84 Opcode Caching Tools........ Alternative phP cache XCache… 95 Caching with Xcache XCache Settings.…., 97 ■ coNtENTS aCcelerator 99 eA Settings… 日面B自日面面 …104 Summary.. ……107 Chapter 5: Variable Caching. a IRRBAIIRBIBRIRaIRIRImRaI 109 Application Performance Roadmap…… ,109 The Value of Implementing Variable Caching 110 A Sample Project: Creating the Table aaaaaamaaaaanamnauue 112 Fetching the records 114 Calculating a Database Fetch….......,.,,…,,…,………,115 APC Caching Adding Data to cache. Benchmarking APC .......................... 121 Memcached 123 Installing Memcached 124 Starting Memcached Server……… …124 ing Memcached with PHP Summary....,,,……,129 Chapter 6: choosing the Right Web server aa 看看看看看道看看看道看道 131 Choosing Which Web Server Package Is for You...s... 132 Security and Stability are Important to You 132 Availability of Engineers with Detailed Knowledge Is Important to You... 133 Your Site Is Predominantly Static Content 133 You are Hosting in a Managed Service 133 You Are Using Unusual PHP Extensions....................133 Usage Figures for Web servers. Web server Request Handling......... 134 Web server hardware 136 Classifying Web Servers 136 Apache HttpD 137 ■ CONTENTS Apache Daemon Command line.......... 138 Apache Multi- processing Modules...,.........,,,,…,……,140 Understanding Apache Modules …141 Adding Dynamic Apache Modules.... 142 Removing Dynamic Apache Module Final Words on apache. lighttpd..esesememeeoeeeeeeseeeeaet …1444 Installinglighttpd...... 144 lighttpdConfigurationSettings...... 148 Comparing Static Load Content 149 InstallingPhponlighttpd........e...a....a. 150 Ngⅰnx 153 Installing Nginx............ 153 Windows installation 157 Nginx As a Static Web Server……....,.,,158 Installing FastcGI PHP NGinx Benchmarking 162 Summary 163 Chapter 7: Web Server and Delivery optimization mmmmmmnmmmmmnamammm 165 Determining the performance of your Web Server 166 Using ApacheTop a Real-Time Access Log File analyzer.. ……166 Understanding the Memory Footprint of Your application. .n …168 Optimizing processes in apache as.oenone 170 Controlling Apache Clients(Prefork MPM) …170 Optimizing Memory Use and Preventing Swapping Other apache Configuration Tweaks Using. htaccess Files and AllowOverride .172 Using follow Symlinks 173 Using DirectoryIndex …173 ■ coNTEnTS Hostname Lookup0ff.…… …174 174 Using mod deflate to Compress Content.. 174 Scaling beyond a Single server..esn. 176 Using round-Robin DNS 176 sing a Load Balancer..... 176 Using Direct Server Return 179 Sharing sessions between Members of a Farm Sharing Assets with a Shared File System 181 Sharing assets with a separate asset server..a. 182 Sharing Assets with a content Distribution Network............. Pitfalls of Using Distributed Architectures. ..amamnamamamnmmnma 184 Cache coherence issues 184 Cache Versioning Issu 184 User IP Address Tracking.......... Domino or cascade failure effects …186 Deployment Failures …187 Monitoring your application .mm Some monitoring Systems for You to Investigate. Summary.…,.....,.,,,,,,,, 188 Chapter 8: Database Optimization Imma RIBBIRIRIB RIBRERIBERIB RIREI. 189 About MySQL n190 Understanding MysQL Storage Engines..................... 191 MyISAM: The original Engine.…… 192 InnoDb: the pros choice 192 Choosing a Storage Engine 193 Understanding How mySQL Uses Memory ■■■■■■■■■■■■■■■■■■■■■■■■■■』■■■■■■■■■■■■■■■a口a■anaa■a1 ,194 InnoDB VS MyISAM Memory Usage Per Server Vs per Connection( Thread) Memory Usage .....................................195 ocating your Configuration File.

...展开详情
试读 127P Pro PHP Application Performance
立即下载 低至0.43元/次 身份认证VIP会员低至7折
一个资源只可评论一次,评论内容不能少于5个字
您会向同学/朋友/同事推荐我们的CSDN下载吗?
谢谢参与!您的真实评价是我们改进的动力~
上传资源赚钱or赚积分
最新推荐
Pro PHP Application Performance 9积分/C币 立即下载
1/127
Pro PHP Application Performance第1页
Pro PHP Application Performance第2页
Pro PHP Application Performance第3页
Pro PHP Application Performance第4页
Pro PHP Application Performance第5页
Pro PHP Application Performance第6页
Pro PHP Application Performance第7页
Pro PHP Application Performance第8页
Pro PHP Application Performance第9页
Pro PHP Application Performance第10页
Pro PHP Application Performance第11页
Pro PHP Application Performance第12页
Pro PHP Application Performance第13页
Pro PHP Application Performance第14页
Pro PHP Application Performance第15页
Pro PHP Application Performance第16页
Pro PHP Application Performance第17页
Pro PHP Application Performance第18页
Pro PHP Application Performance第19页
Pro PHP Application Performance第20页

试读结束, 可继续阅读

9积分/C币 立即下载 >