Accelerating PHP Applications Ilia Alshanetsky O’Reilly Open Source Convention August 3rd, 2005.

Slides:



Advertisements
Similar presentations
Case Study: Photo.net March 20, What is photo.net? An online learning community for amateur and professional photographers 90,000 registered users.
Advertisements

Module 13: Performance Tuning. Overview Performance tuning methodologies Instance level Database level Application level Overview of tools and techniques.
MCTS GUIDE TO MICROSOFT WINDOWS 7 Chapter 10 Performance Tuning.
Toolbox Mirror -Overview Effective Distributed Learning.
ManageEngine TM Applications Manager 8 Monitoring Custom Applications.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 11: Monitoring Server Performance.
Chapter 14 Chapter 14: Server Monitoring and Optimization.
Multiple Tiers in Action
IS4401 Project Technology Issues. Introduction This seminar covers Databases When to use a Database What Database to use Development Tools Visual Studio.
Apache Tomcat Server Typical html Request/Response cycle
Analysis and Performance Information Systems 337 Prof. Harry Plantinga.
1 Tuning PL/SQL procedures using DBMS_PROFILER 20-August 2009 Tim Gorman Evergreen Database Technologies, Inc. Northern California Oracle.
22-Aug-15 | 1 |1 | Help! I need more servers! What do I do? Scaling a PHP application.
Managing PHP Performance By: Ilia Alshanetsky. 2Performance Compiler/Opcode Caches This cycle happens for every include file, not just for the "main"
This presentation will guide you though the initial stages of installation, through to producing your first report Click your mouse to advance the presentation.
6/1/2001 Supplementing Aleph Reports Using The Crystal Reports Web Component Server Presented by Bob Gerrity Head.
M. Taimoor Khan * Java Server Pages (JSP) is a server-side programming technology that enables the creation of dynamic,
Bob Thome, Senior Director of Product Management, Oracle SIMPLIFYING YOUR HIGH AVAILABILITY DATABASE.
SIMPLE ROUTER The slide made by Salim Malakouti. Next we will create the Router  What do I we mean by a router?  Routers work similar to a map. It receives.
Database Systems Design, Implementation, and Management Coronel | Morris 11e ©2015 Cengage Learning. All Rights Reserved. May not be scanned, copied or.
Database Systems: Design, Implementation, and Management Eighth Edition Chapter 10 Database Performance Tuning and Query Optimization.
About Dynamic Sites (Front End / Back End Implementations) by Janssen & Associates Affordable Website Solutions for Individuals and Small Businesses.
Building Highly Scalable Websites Karol Jarkovsky Sr. Solution Architect
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
CS 345: Topics in Data Warehousing Tuesday, October 19, 2004.
Computer Measurement Group, India Optimal Design Principles for better Performance of Next generation Systems Balachandar Gurusamy,
Copyrighted material John Tullis 10/6/2015 page 1 Performance: WebSphere Commerce John Tullis DePaul Instructor
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 11: Monitoring Server Performance.
9 Chapter Nine Compiled Web Server Programs. 9 Chapter Objectives Learn about Common Gateway Interface (CGI) Create CGI programs that generate dynamic.
MySQL. Dept. of Computing Science, University of Aberdeen2 In this lecture you will learn The main subsystems in MySQL architecture The different storage.
Ideas to Improve SharePoint Usage 4. What are these 4 Ideas? 1. 7 Steps to check SharePoint Health 2. Avoid common Deployment Mistakes 3. Analyze SharePoint.
Accelerating PHP Applications Ilia Alshanetsky
Database-Driven Web Sites, Second Edition1 Chapter 5 WEB SERVERS.
Improving Efficiency of I/O Bound Systems More Memory, Better Caching Newer and Faster Disk Drives Set Object Access (SETOBJACC) Reorganize (RGZPFM) w/
CakePHP is an open source web development framework. It follows Model-View- Controller and is developed using PHP. IT is the basic for user to create.
CSC 2720 Building Web Applications Improving Web Application Performance.
PHP & Performance By: Ilia Alshanetsky. 1 Compiler/Opcode Caches  This cycle happens for every include file, not just for the "main" script.  Compilation.
Implementation - Part 2 CPS 181s March 18, Pieces of the Site-building Puzzle Page 180, figure 4.1.
The HipHop Compiler from Facebook By Megha Gupta & Nikhil Kapoor.
DBMS Implementation Chapter 6.4 V3.0 Napier University Dr Gordon Russell.
Kiew-Hong Chua a.k.a Francis Computer Network Presentation 12/5/00.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment, Enhanced Chapter 11: Monitoring Server Performance.
By Shanna Epstein IS 257 September 16, Cnet.com Provides information, tools, and advice to help customers decide what to buy and how to get the.
6/1/2001 Supplementing Aleph Reports Using The Crystal Reports Web Component Server Presented by Bob Gerrity Head.
AxKit A member of the Apache XML project Ryan Maslyn Kyle Bechtel.
ASP (Active Server Pages) by Bülent & Resul. Presentation Outline Introduction What is an ASP file? How does ASP work? What can ASP do? Differences Between.
PERFORMANCE ENHANCEMENT IN ASP.NET By Hassan Tariq Session #1.
Implementing ISA Server Caching
PHP Performance w/APC + thaicyberpoint.com thaithinkpad.com thaihi5.com.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
Web Browsing *TAKE NOTES*. Millions of people browse the Web every day for research, shopping, job duties and entertainment. Installing a web browser.
Apache Web Server Architecture Chaitanya Kulkarni MSCS rd April /23/20081Apache Web Server Architecture.
for all Hyperion video tutorial/Training/Certification/Material Essbase Optimization Techniques by Amit.
Text TCS INTERNAL Oracle PL/SQL – Introduction. TCS INTERNAL PL SQL Introduction PLSQL means Procedural Language extension of SQL. PLSQL is a database.
Fundamentals of Web DevelopmentRandy Connolly and Ricardo HoarFundamentals of Web DevelopmentRandy Connolly and Ricardo Hoar Fundamentals of Web DevelopmentRandy.
Web Cache. What is Cache? Cache is the storing of data temporarily to improve performance. Cache exist in a variety of areas such as your CPU, Hard Disk.
Diagnosing Problems DAD5 © Copyright 2011 Mitchel Sellers – May Not Be Reused without Permission.
Presented By Sushil K. Chaturvedi Assistant Professor SRCEM,Banmore 1.
L.A.M.P. İlker Korkmaz & Kaya Oğuz CS 350. Why cover a lecture on LAMP? ● Job Opportunities – There are many hosting companies offering LAMP as a web.
Managing State Chapter 13.
Informatica PowerCenter Performance Tuning Tips
BTEC NCF Dip in Comp - Unit 15 Website Development Lesson 05 – Website Performance Mr C Johnston.
Database Performance Tuning and Query Optimization
Marcos Freccia Stop everything! Top T-SQL tricks to a developer
Laruence 14-May-2011 PHP Performance laruence 14-May-2011.
Scaling and Performance
Moodle Scalability What is Scalability?
Nate Nelson I*LEVEL, Inc.
Chapter 11 Database Performance Tuning and Query Optimization
Yale Digital Conference 2019
Presentation transcript:

Accelerating PHP Applications Ilia Alshanetsky O’Reilly Open Source Convention August 3rd, 2005

Bytecode/Opcode Caches  This cycle happens for every include file, not just for the "main" script.  Compilation can easily consume more time than execution.

Opcode Caches Benefits:  Each PHP script is compiled only once for each revision.  Reduced File IO thanks to opcodes being read from memory rather then being parsed from disk.  Since compilation is one time event, generated opcodes can optimised for faster execution.

Opcode Caches: Implementations APC (Alternative PHP Cache) –Open Source –Works with PHP 5.0+ –Easy to install (pecl install apc) –Being actively maintained eAccelerator (Turck MMCache) –Open Source –Kinda/Sorta/Maybe works with PHP 5.0 –VERY FAST (fastest cache for 4.X) Zend Performance Suit –On par performance with APC –Includes other acceleration tools (content caching)

Compiler Optimisations For absolute maximum performance it may be a good idea to ensure that all software is compiled to the take maximum advantage of the available hardware.  Enable all compiler optimizations with -O3  Make the compiler tune the code to your CPU via -march -mcpu  Try to make the compiler use CPU specific features -msse -mmmx - mfpmath=sse export CFLAGS="-O3 -msse -mmmx -march=pentium3 \ -mcpu=pentium3 -funroll-loops -mfpmath=sse"

Apache/PHP Integration For maximum performance compile PHP statically into Apache (up to 30% speed increase). Or use PHP where --prefer- non-pic is default. How to compile PHP statically into Apache # PHP./configure --with-apache=/path/to/apache_source # Apache./configure --activate-module=src/modules/php4/libphp4.a

Web Server: File IO  Keep DirectoryIndex file list as short as possible.  Whenever possible disable.htaccess via AllowOverride none.  Use Options FollowSymLinks to simplify file access process in Apache.  If logs are unnecessary disable them.  If logging is a must, log everything to 1 file and break it up during analysis stage.

Bandwidth Optimizations Less output is good because…  Saves server bandwidth (saves $$ too).  Reduces server resource usage (CPU/Memory/Disk)  Pages load faster for clients.  Reduces network IO high traffic sites, where it is the primary bottleneck in most cases.

Content Compression  Most browser support retrieval of compressed pages decompressing them before rendering.  Compressed pages are on average are 7-10 times smaller, however compression can take 3%-5% of CPU. Implementations:  Apache 1 (mod_gzip)  Apache 2 (mod_deflate)  PHP  php.ini ( zlib.output_compression=1 )  script (ob_start(“ob_gzhandler”) )

Tuning PHP Configuration  register_globals = Off **  magic_quotes_gpc = Off  expose_php = Off  register_argc_argv = Off  always_populate_raw_post_data = Off **  session.use_trans_sid = Off **  session.auto_start = Off **  session.gc_divisor = 1000 or  output_buffering = 4096 ** Off by default

Tuning PHP File Access Whenever opening files or including scripts into the main script try to specify a full path or at least an easily resolvable partial path. Bad Approach: Performance Friendly Approach:

Regular Expressions While very useful tool for string manipulation, regular expression leave much to be desired when it comes to performance.

Reference Tricks References can be a valuable tool to simplify and accelerate access to complex data types as well as a memory saving tool.

What Is Caching? Caching is the recognition and exploitation of the fact that most "dynamic" data does not change every time you request it.

Pros and Cons of Caching  Pros: – Significant Speed Increases – Reduction in consumption of some resources  Cons: –Increase in Architectural Complexity –Potential for Stale or Inconsistent Data

On-Demand Caching Set up a 404 error handler in.htaccess: RewriteEngine on RewriteRule /.*\.[^h][^t][^m][^l]$ /$1.html ErrorDocument 404 /index.php DirectoryIndex index.php

SQL & Performance Most large applications will end up using databases for information storage. Improper use of this resource can lead to significant and continually increasing performance loss.

Check Your Queries Most databases offer mechanisms to analyze query execution and determine if it’s running in an optimal manner. EXPLAIN select * from mm_users where login LIKE '%ilia%'; | table | type | possible_keys | key | key_len | ref | rows | Extra | | mm_users | ALL | NULL | NULL | NULL | NULL | | where used | EXPLAIN select * from mm_users where login LIKE 'ilia%'; | table | type | possible_keys | key | key_len | ref | rows | Extra | | mm_users | range | login | login | 50 | NULL | 2 | where used | SLOW FAST

Questions