SlideShare a Scribd company logo
Performance Tuning PHP on IBM i

Mike Pavlak                   Alan Seiden
Solution Consultant           Strategic Business Systems


Watch the recorded webinar: http://bit.ly/A4NjYM




                                                    © All rights reserved. Zend Technologies, Inc.
Agenda

    • What affects performance
    • Zend Server configuration
    • Review hardware architecture
    • Explore Web specific opportunities
    • Where to get additional help
    • Wrap up
    • Q&A




2                         © All rights reserved. Zend Technologies, Inc.
Performance is in the eye of the beholder…
    Perception is reality
      Many pieces to the performance puzzle

      Rarely a single silver bullet

      Performance tuning is a journey, not a destination

      Learn as you go

      Commercial websites look great…
          • And can be great motivators for change
      PHP is often accused but rarely convicted




3                             © All rights reserved. Zend Technologies, Inc.
Major contributors to performance issues

    • Additive workload
    • Transitional workload
    • Organic growth
    • Network infrastructure
    • Entropy
    • A piece of advice…
         When you see these coming…GET IN FRONT OF THEM
                 • Or get run over!




4   Insert->Header & Footer           © All rights reserved. Zend Technologies, Inc.
Speed = money
• Google’s experiment
   Google Search lists 10 results per page


   They tested pages of 30 results
           • Traffic and revenue dropped by 20%
           • Why?
                   – 10 results took .4 seconds to generate
                   – 30 results took .9 seconds
           • A ½ second delay caused a 20% drop in traffic
   Source:
       http://glinden.blogspot.com/2006/11/marissa
       -mayer-at-web-20.html


 Performance Tuning PHP on IBM i | 5   © All rights reserved. Zend Technologies, Inc.
Speed = competitiveness

• Search engine ranking
      Since early 2010, Google’s search algorithm has included speed

      Faster sites rank higher, all else being equal



• Consumers lose patience with slow sites
      With many choices, users give up on sites that drag

      Patience has decreased since the 1990s



• Slower sites often waste bandwidth and CPU
      Costly infrastructure driven by performance mistakes

Performance Tuning PHP on IBM i | 6   © All rights reserved. Zend Technologies, Inc.
How do we improve performance

    • Subject of this webinar
         Doing what you are doing now!

    • From the softer side
         Communication with other teams is essential
                 • While it is encouraged to bang you head against the wall…
                 • Do not suffer in silence, reach out for help
         Education
                 • If you think education is expensive, try ignorance!
         Services
                 • There are folks who may know more than you. Hire them.


7   Insert->Header & Footer           © All rights reserved. Zend Technologies, Inc.
Performance Tuning PHP on IBM i

www.zend.com




 Looking at Zend Server Administration




                © All rights reserved. Zend Technologies, Inc.
Zend Server for IBM i 5.6

    • Zend Server is Home Base
    • Configuration options abound
    • We will look at
         FastCGI settings

         Logs

         Extensions




9   Insert->Header & Footer   © All rights reserved. Zend Technologies, Inc.
Fast CGI

     • Mechanism for communicating between Apache and PHP
     • Built in with 10 server jobs at the time of installation
     • This should conform to concurrent processes
     • Watch this as more workload is migrated to web




10   Insert->Header & Footer   © All rights reserved. Zend Technologies, Inc.
Fast CGI
     • Changing this
          is something that should be considered

          But not taken lightly (system resources, etc.)

     • File to edit:
          /www/zendsvr/conf/fastcgi.conf

          SetEnv="PHP_FCGI_CHILDREN=10"

     • But don’t forget…
          StartProcesses = “2” * PHP_FCGI_CHILDREN = 8 is 16 total worker jobs

          http://www.youngiprofessionals.com/wiki/FastCGI

          http://www.systeminetwork.com/article/other-
              languages/fastcgi-boosts-php-performance-on-ibm-i-66195

11   Insert->Header & Footer      © All rights reserved. Zend Technologies, Inc.
PHP Logs

     • IFS performance, minimize read/writes
          Alan will discuss more

          But what about the logs

     • Consider the event monitor
     • Read the logs
     • Reduce the messages
     • Clip the log
          /usr/local/zendsvr/var/log/php.log




12   Insert->Header & Footer   © All rights reserved. Zend Technologies, Inc.
Rename the log
     • Zend Server will create more!
           REN OBJ('/usr/local/zendsvr/var/log/php.log') NEWOBJ(phplog20120306.txt)




13   Insert->Header & Footer      © All rights reserved. Zend Technologies, Inc.
Extensions
     • PHP travels with a posse
          70+ extensions

          Many are used every day

          But if not used, may be turned off…

          Default,
                  • Zend Server for IBM i shipped with DB2 on and SQL Server off
                  • Look at the Zend Server admin interface
                           – Server setup  Extensions
                           – Like a light switch




14   Insert->Header & Footer                  © All rights reserved. Zend Technologies, Inc.
IBM i administration

     • PTF’s
          Current cumulative & group for HTTP

     • Memory pools
          Isolate memory from other attacks

     • Workload partitioning
          With i6.1 & i7.1 can protect processor without LPAR

     • Understanding demands on the systems
          If the boss doesn’t believe you, have your BP back you up!

          Performance Monitor tools

          3rd party

15   Insert->Header & Footer    © All rights reserved. Zend Technologies, Inc.
WRKSYSSTS – The first place to go!!!




16   Insert->Header & Footer   © All rights reserved. Zend Technologies, Inc.
Performance Tuning PHP on IBM i

www.zend.com




 Tools




               © All rights reserved. Zend Technologies, Inc.
Firebug add-on graphs performance

• Firebug
      https://addons.mozilla.org/firefox/addon/firebug/

      Even better with FirePHP and Page Speed




Performance Tuning PHP on IBM i | 18   © All rights reserved. Zend Technologies, Inc.
Performance Tuning PHP on IBM i

www.zend.com




 Use Compression




               © All rights reserved. Zend Technologies, Inc.
Compression reduces file size
• Called gzip or mod_deflate (the same for our purposes)




• Compresses, speeds up html, javascript, css, any text
• Add two lines (OK, two long lines) to httpd.conf Apache config
       LoadModule deflate_module
          /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM
       AddOutputFilterByType DEFLATE application/x-httpd-php
          application/json text/css application/x-javascript
          application/javascript text/html


Performance Tuning PHP on IBM i | 20   © All rights reserved. Zend Technologies, Inc.
Netflix saw improvement with gzip/deflate

• Saw 13-25% performance improvement
• Cut outbound traffic in half
      That saves money for a busy site such as Netflix

• Details of Netflix improvement:
      http://www.slideshare.net/billwscott/improving-netflix-
          performance-experience
• It really works!
• Tutorial on my blog:
      http://www.alanseiden.com/2010/08/13/maximize-zend-
          server-performance-with-apache-compression/


Performance Tuning PHP on IBM i | 21   © All rights reserved. Zend Technologies, Inc.
Performance Tuning PHP on IBM i

www.zend.com




 Reduce HTTP Requests




               © All rights reserved. Zend Technologies, Inc.
Requests cause “blocking” in browser

• Browsers typically limit themselves to 2 parallel requests to
  a given server
• File requests stack up, blocked by prev. requests
•




• Above, even “not modified” files caused blocking
• Solution: reduce number of images or improve
      caching via “Expires” headers
         http://httpd.apache.org/docs/2.0/mod/mod_expires.html

Performance Tuning PHP on IBM i | 23   © All rights reserved. Zend Technologies, Inc.
More ways to reduce “blocking”

• If many .js or .css files are used:
      Combine them into fewer files

      Move contents of smaller .js or .css files inline to your pages,
          eliminating those external files
      Page Speed tool will help you decide




Performance Tuning PHP on IBM i | 24   © All rights reserved. Zend Technologies, Inc.
Performance Tuning PHP on IBM i

www.zend.com




 Ajax: friend or foe?




                 © All rights reserved. Zend Technologies, Inc.
AJAX=Asynchronous Javascript And XML

• AJAX updates parts of a page without reloading the whole
  page
• Not always XML. These days, JSON too
• Requests and file sizes are generally small
• Meant to bring SPEED to the web


• Potential problems if overused




Performance Tuning PHP on IBM i | 26   © All rights reserved. Zend Technologies, Inc.
AJAX mistake #1
• Too much of a good thing
      Requiring several AJAX requests to complete before the page
          itself can load fully
      Too many HTTP requests at once
      I’ve seen a situation where 4 AJAX requests were embedded in a
          page load
              • The AJAX doesn’t even start till the page loads
              • Causes “blocking” as the requests pile up, waiting for the previous
                ones to complete
      Solution: when page first loads, embed AJAX content right in the
          page
              • Re-use logic on the server side when building page
              • Subsequent updates can be done with AJAX

Performance Tuning PHP on IBM i | 27   © All rights reserved. Zend Technologies, Inc.
AJAX mistake #2

• Duplicate requests
      Might go unnoticed with javascript library tools (Dojo, jQuery...)

      Happens more than you would expect! Common, actually




Performance Tuning PHP on IBM i | 28   © All rights reserved. Zend Technologies, Inc.
AJAX mistake #3
 • Dynamically generating static content (don’t do that)
 • Solutions:
        Change to static files

        Cache URLs (e.g. with Zend Data Cache if using PHP, or Apache caching)
           See example below, before and after caching




Performance Tuning PHP on IBM i | 29   © All rights reserved. Zend Technologies, Inc.
Performance Tuning PHP on IBM i

www.zend.com




 Keep-alive




               © All rights reserved. Zend Technologies, Inc.
Keep HTTP connections alive
• “Keep-alive” setting in Apache (or any web server)


• The HTTP job will stay open, waiting for you
      Perfect when downloading many images, css, js files



• Configurable by number of seconds to keep connection open,
  number of files to be downloaded
      KeepAlive On

      KeepAliveTimeout 15

      See http://httpd.apache.org/docs/2.0/mod/core.html#keepalive



• Don’t overdo it—you are locking out other users from that HTTP
  job while it’s dedicated to you
Performance Tuning PHP on IBM i | 31   © All rights reserved. Zend Technologies, Inc.
Connecting takes time

• Clues that Keepalive is off
      “Connection: close”, “Connecting”

• Example bottom right: 3.6 seconds “Connecting” (longer
  than average but it really happened)




Performance Tuning PHP on IBM i | 32   © All rights reserved. Zend Technologies, Inc.
What you see when Keep-alive is on

• Firebug’s “Net” tab shows “Connection: Keep-Alive”, and,
  here, timeout=300 seconds (5 minutes)




    • Zero seconds to
    connect
    • Keep-alive is working!



Performance Tuning PHP on IBM i | 33   © All rights reserved. Zend Technologies, Inc.
Performance Tuning PHP on IBM i

www.zend.com




 Persistent DB Connections




                © All rights reserved. Zend Technologies, Inc.
Persistence = connection pool

• On IBM i, job initialization is relatively slow
      Gives us good things—auditing, logging, security

      Solution: a pool of pre-initialized jobs


• Pre-started DB2 jobs save time
      Generally run in subsystem QSYSWRK, job name QSQSRVR

      These prestart jobs can be configured with CHGPJE command


• In PHP, persistent connections reuse initialized jobs
      db2_pconnect()

      Dramatic speed boost
Performance Tuning PHP on IBM i | 35   © All rights reserved. Zend Technologies, Inc.
Use db2_pconnect() to connect persistently
• resource db2_pconnect ( string $database , string
  $username , string $password [, array $options ] )


• Persistent is much faster than non-persistent
     db2_pconnect can reuse connections, reducing the time needed
        to connect (after the first time) to almost zero
• How db2_pconnect() reuses connections
     Connections defined by database, username, and password

     Tries to reuse an existing connection matching these 3 params

     db2_close() on a persistent connection does nothing

     db2_pclose() forces the conn to close

Performance Tuning PHP on IBM i | 36   © All rights reserved. Zend Technologies, Inc.
db2_pconnect() example with library list
$database = 'MYDB';
$user = 'MYUSER';
$password = 'MYPASS';

// set library list (works the same for connect or pconnect)
$options = array('i5_naming'                             => DB2_I5_NAMING_ON,
                                   'i5_libl'             => 'MYLIB1 MYLIB2');
$conn = db2_pconnect($database, $user, $password, $options);

if ($conn) {
       echo "Connection succeeded.";
} else {
    echo "Connection failed.";
}
// MYTABLE will be found, if in library MYLIB1 or MYLIB2
$stmt=db2_exec($conn,"SELECT * FROM MYTABLE");

Performance Tuning PHP on IBM i | 37      © All rights reserved. Zend Technologies, Inc.
Rules for using persistence
• Because connections are shared when defined with an
  identical database, user, and password, please:
     Avoid unpredictable results by also specifying the same $options
        for these connections
     Promote sharing of jobs by minimizing the number of user profiles
        that you connect with
             • Each user profile creates a new set of database jobs
             • Each set of jobs consumes system resources



• More information:
     “DB2 and PHP Best Practices on IBM i” at
        http://alanseiden.com/presentations

Performance Tuning PHP on IBM i | 38   © All rights reserved. Zend Technologies, Inc.
New open source PHP IBM i toolkit
• Ships with Zend Server 5.6+
      PTFs and hotfixes on download page
      Many improvements since first release


• Information and updates:
      Young i Professionals site
              • http://youngiprofessionals.com/wiki/XMLSERVICE
      Zend Forum for Q&A and tips
              • http://forums.zend.com/viewtopic.php?f=113&t=41648
              • “PHP on IBM i”->”Zend Server for IBM i”->”New Toolkit”


• Efficient: use single DB2 connection for SQL and Toolkit
      http://forums.zend.com/viewtopic.php?f=113&t=46688
      Persistent connection is the fastest
Performance Tuning PHP on IBM i | 39   © All rights reserved. Zend Technologies, Inc.
Performance Tuning PHP on IBM i

www.zend.com




 Wrap it up




               © All rights reserved. Zend Technologies, Inc.
Help!

     • I’ve got PHP applications and not sure what to do?
     • Do your homework
          Read, learn, explore

          Talk in forums (Zend.com and midrange.com)

     • Zend Services
          Application Audit
                  • Up to 50,000 lines of code
                  • Review on site or off (knowledge transfer!)
                  • Report summary & remediation available




41   Insert->Header & Footer           © All rights reserved. Zend Technologies, Inc.
Zend Performance Audit
      Comprehensive Methodology
          Detailed evaluation of your application and environment
          Detailed analysis of performance patterns and behaviors
          Provide report and improvements recommendations
      Proven Success
          Delivered to numerous Global 1000 companies
          Accelerated performance across industries
          Methodologies applied to hundreds of applications
      Delivered by the PHP Company Experts
          Unparalleled experience in PHP and Zend Server
          Methodology developed by the architects of PHP
          Utilizing Zend standard benchmarks




42   Zend Professional Services     © All rights reserved. Zend Technologies, Inc.
Zend Server features (Full version)

     • Event Monitor
          Become aware of issues before your users call

     • Code Tracing
          Black box flight recorder for PHP scripts

     • Caching
          Op-code (Alan discussed & available with CE)

          Data (Also available with CE)

          Page

     • Job Queue
          SBMJOB for PHP!!!

43   Insert->Header & Footer    © All rights reserved. Zend Technologies, Inc.
Webcasts

     • April 12 – Stored Procedures Part II (RPG, etc.)
     • May 2 – Additional Functions of DB2 with PHP on IBM i




                       Your thoughts???

44   Insert->Header & Footer   © All rights reserved. Zend Technologies, Inc.
Events where you’ll find Zend…
     • User groups
          WMCPA (Lake Geneva, WI) Mar 20-22 (Mike & Alan)
                  • http://wmcpa.org/
          NEUGC (Boston, MA) April 2-4
                  • http://neugc.org/

     Alan:
     March 29: COMMON webcast: more performance tips
     http://www.common.org/index.php/webcasts/upcoming-webcasts.html

     April 5: live online event with System i Network
     New PHP Toolkit for IBM i
     http://www.systeminetwork.com/events/upcoming-events

     In New York City? I host the NYC Zend Framework Meetup
     http://www.meetup.com/ZendFramework-NYCmetro/
45   Insert->Header & Footer            © All rights reserved. Zend Technologies, Inc.
Events where you’ll find Zend…(cont.)
     • Major venues
          RPG & DB2 Summit (Ft. Worth, TX) Mar 25-28
                  • http://www.systemideveloper.com/Summit/conferences.html




          COMMON Annual Meeting and Expo (Anaheim, CA) May 6-9
                  • http://www.common.org/index.php/annualmeeting.html




          COMMON Fall Conference (Columbus, OH) Sep 24-26
                  • http://www.common.org/index.php/fall-conference-and-expo.html


46   Insert->Header & Footer        © All rights reserved. Zend Technologies, Inc.
Contact | Get tips
Alan Seiden                                           Strategic Business Systems, Inc,
201-327-9400                                          17 S. Franklin Tpk
aseiden@sbsusa.com                                    Ramsey, NJ, 07446


http://alanseiden.com                                 Twitter: @alanseiden


Free PHP/i tips by email:
http://alanseiden.com/tips




Performance Tuning PHP on IBM i | 47   © All rights reserved. Zend Technologies, Inc.
Q&A
     mike.p@zend.com

     aseiden@sbsusa.com
      Watch the recorded webinar: http://bit.ly/A4NjYM




48                © All rights reserved. Zend Technologies, Inc.

More Related Content

PPTX
Getting started with PHP on IBM i
PDF
Running open source PHP applications on you IBM i
PDF
Web services on IBM i with PHP and Zend Framework
PDF
Web Performance First Aid
PDF
IBM i: Fertile Ground for PHP Developers
PDF
Create a welcoming development environment on IBM i
PPTX
Fundamentals of performance tuning PHP on IBM i
PDF
From Zero to ZF: Your first zend framework project on ibm i
Getting started with PHP on IBM i
Running open source PHP applications on you IBM i
Web services on IBM i with PHP and Zend Framework
Web Performance First Aid
IBM i: Fertile Ground for PHP Developers
Create a welcoming development environment on IBM i
Fundamentals of performance tuning PHP on IBM i
From Zero to ZF: Your first zend framework project on ibm i

What's hot (20)

PDF
PHP Toolkit from Zend and IBM: Open Source on IBM i
PDF
DB2 and PHP in Depth on IBM i
PDF
Strategic Modernization with PHP on IBM i
PDF
Performance tuning with zend framework
PDF
Browser tools that make web development easier
PPTX
Zend Products and PHP for IBMi
PDF
PHP Batch Jobs on IBM i
PPTX
PHP on IBM i Tutorial
PDF
Adm02 Be a Domino Detective: Tackling Your Toughest Performance Problems
PDF
Adm07 The Health Check Extravaganza for IBM Social and Collaboration Environm...
PPTX
Optimizing performance
PDF
A Tale of Two Toolkits
PDF
IBM Connect 2016 - 60+ in 60 - Admin Tips Power Hour
PDF
Practical solutions for connections administrators lite
PDF
Taking IBM Sametime Mobile
PDF
IBM Connections administration – keep your systems running the right way
PPTX
Best And Worst Practices Deploying IBM Connections
PDF
Webinar: IBM Connections Adminblast
PDF
You don't want to do it like that
PDF
Sa106 – practical solutions for connections administrators
PHP Toolkit from Zend and IBM: Open Source on IBM i
DB2 and PHP in Depth on IBM i
Strategic Modernization with PHP on IBM i
Performance tuning with zend framework
Browser tools that make web development easier
Zend Products and PHP for IBMi
PHP Batch Jobs on IBM i
PHP on IBM i Tutorial
Adm02 Be a Domino Detective: Tackling Your Toughest Performance Problems
Adm07 The Health Check Extravaganza for IBM Social and Collaboration Environm...
Optimizing performance
A Tale of Two Toolkits
IBM Connect 2016 - 60+ in 60 - Admin Tips Power Hour
Practical solutions for connections administrators lite
Taking IBM Sametime Mobile
IBM Connections administration – keep your systems running the right way
Best And Worst Practices Deploying IBM Connections
Webinar: IBM Connections Adminblast
You don't want to do it like that
Sa106 – practical solutions for connections administrators
Ad

Similar to Performance tuning PHP on IBMi (20)

PDF
What's new with Zend server
PPTX
High performance PHP: Scaling and getting the most out of your infrastructure
PDF
Getting started with PHP on IBM i
PPTX
Turbocharging php applications with zend server
PDF
Turbocharging php applications with zend server (workshop)
PDF
Application Deployment on IBM i
PPT
introduction to php notes for engineering students.ppt
PDF
Integrating PHP With System-i using Web Services
PPTX
Building and managing applications fast for IBM i
PPTX
PHP Apps on the Move - Migrating from In-House to Cloud
PPT
Ria Applications And PHP
PPT
Microsoft TechDays 2011 - PHP on Windows
PDF
Scalable High-Availability Session Storage with ZSCM
PDF
DPC2007 Zend Framework (Gaylord Aulke)
 
PDF
Dutch php conference_2010_opm
PPTX
ExpressionEngine - Simple Steps to Performance and Security (EECI 2014)
PDF
Performance tuning of Websites
PDF
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
PDF
Web Performance Optimization (WPO)
What's new with Zend server
High performance PHP: Scaling and getting the most out of your infrastructure
Getting started with PHP on IBM i
Turbocharging php applications with zend server
Turbocharging php applications with zend server (workshop)
Application Deployment on IBM i
introduction to php notes for engineering students.ppt
Integrating PHP With System-i using Web Services
Building and managing applications fast for IBM i
PHP Apps on the Move - Migrating from In-House to Cloud
Ria Applications And PHP
Microsoft TechDays 2011 - PHP on Windows
Scalable High-Availability Session Storage with ZSCM
DPC2007 Zend Framework (Gaylord Aulke)
 
Dutch php conference_2010_opm
ExpressionEngine - Simple Steps to Performance and Security (EECI 2014)
Performance tuning of Websites
The 5 most common reasons for a slow WordPress site and how to fix them – ext...
Web Performance Optimization (WPO)
Ad

More from Zend by Rogue Wave Software (20)

PDF
Develop microservices in php
PPTX
Speed and security for your PHP application
PDF
Building web APIs in PHP with Zend Expressive
PPTX
To PHP 7 and beyond
PDF
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
PDF
The Sodium crypto library of PHP 7.2 (PHP Day 2018)
PDF
Develop web APIs in PHP using middleware with Expressive (Code Europe)
PDF
Middleware web APIs in PHP 7.x
PPTX
Ongoing management of your PHP 7 application
PDF
Developing web APIs using middleware in PHP 7
PDF
The Docker development template for PHP
PDF
The most exciting features of PHP 7.1
PPTX
Unit testing for project managers
PDF
The new features of PHP 7
PPTX
Deploying PHP apps on the cloud
PPTX
Data is dead. Long live data!
PPTX
Resolving problems & high availability
PPTX
Developing apps faster
PPTX
Keeping up with PHP
PDF
Continuous Delivery e-book
Develop microservices in php
Speed and security for your PHP application
Building web APIs in PHP with Zend Expressive
To PHP 7 and beyond
Speed up web APIs with Expressive and Swoole (PHP Day 2018)
The Sodium crypto library of PHP 7.2 (PHP Day 2018)
Develop web APIs in PHP using middleware with Expressive (Code Europe)
Middleware web APIs in PHP 7.x
Ongoing management of your PHP 7 application
Developing web APIs using middleware in PHP 7
The Docker development template for PHP
The most exciting features of PHP 7.1
Unit testing for project managers
The new features of PHP 7
Deploying PHP apps on the cloud
Data is dead. Long live data!
Resolving problems & high availability
Developing apps faster
Keeping up with PHP
Continuous Delivery e-book

Recently uploaded (20)

PDF
Review of recent advances in non-invasive hemoglobin estimation
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPT
Teaching material agriculture food technology
PDF
Empathic Computing: Creating Shared Understanding
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
PPTX
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
cuic standard and advanced reporting.pdf
PDF
Electronic commerce courselecture one. Pdf
PDF
Advanced methodologies resolving dimensionality complications for autism neur...
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Cloud computing and distributed systems.
PDF
Agricultural_Statistics_at_a_Glance_2022_0.pdf
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Approach and Philosophy of On baking technology
Review of recent advances in non-invasive hemoglobin estimation
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Teaching material agriculture food technology
Empathic Computing: Creating Shared Understanding
Machine learning based COVID-19 study performance prediction
Understanding_Digital_Forensics_Presentation.pptx
How UI/UX Design Impacts User Retention in Mobile Apps.pdf
VMware vSphere Foundation How to Sell Presentation-Ver1.4-2-14-2024.pptx
Diabetes mellitus diagnosis method based random forest with bat algorithm
cuic standard and advanced reporting.pdf
Electronic commerce courselecture one. Pdf
Advanced methodologies resolving dimensionality complications for autism neur...
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
Encapsulation_ Review paper, used for researhc scholars
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Unlocking AI with Model Context Protocol (MCP)
Cloud computing and distributed systems.
Agricultural_Statistics_at_a_Glance_2022_0.pdf
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Approach and Philosophy of On baking technology

Performance tuning PHP on IBMi

  • 1. Performance Tuning PHP on IBM i Mike Pavlak Alan Seiden Solution Consultant Strategic Business Systems Watch the recorded webinar: http://bit.ly/A4NjYM © All rights reserved. Zend Technologies, Inc.
  • 2. Agenda • What affects performance • Zend Server configuration • Review hardware architecture • Explore Web specific opportunities • Where to get additional help • Wrap up • Q&A 2 © All rights reserved. Zend Technologies, Inc.
  • 3. Performance is in the eye of the beholder… Perception is reality Many pieces to the performance puzzle Rarely a single silver bullet Performance tuning is a journey, not a destination Learn as you go Commercial websites look great… • And can be great motivators for change PHP is often accused but rarely convicted 3 © All rights reserved. Zend Technologies, Inc.
  • 4. Major contributors to performance issues • Additive workload • Transitional workload • Organic growth • Network infrastructure • Entropy • A piece of advice… When you see these coming…GET IN FRONT OF THEM • Or get run over! 4 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 5. Speed = money • Google’s experiment Google Search lists 10 results per page They tested pages of 30 results • Traffic and revenue dropped by 20% • Why? – 10 results took .4 seconds to generate – 30 results took .9 seconds • A ½ second delay caused a 20% drop in traffic Source: http://glinden.blogspot.com/2006/11/marissa -mayer-at-web-20.html Performance Tuning PHP on IBM i | 5 © All rights reserved. Zend Technologies, Inc.
  • 6. Speed = competitiveness • Search engine ranking Since early 2010, Google’s search algorithm has included speed Faster sites rank higher, all else being equal • Consumers lose patience with slow sites With many choices, users give up on sites that drag Patience has decreased since the 1990s • Slower sites often waste bandwidth and CPU Costly infrastructure driven by performance mistakes Performance Tuning PHP on IBM i | 6 © All rights reserved. Zend Technologies, Inc.
  • 7. How do we improve performance • Subject of this webinar Doing what you are doing now! • From the softer side Communication with other teams is essential • While it is encouraged to bang you head against the wall… • Do not suffer in silence, reach out for help Education • If you think education is expensive, try ignorance! Services • There are folks who may know more than you. Hire them. 7 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 8. Performance Tuning PHP on IBM i www.zend.com Looking at Zend Server Administration © All rights reserved. Zend Technologies, Inc.
  • 9. Zend Server for IBM i 5.6 • Zend Server is Home Base • Configuration options abound • We will look at FastCGI settings Logs Extensions 9 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 10. Fast CGI • Mechanism for communicating between Apache and PHP • Built in with 10 server jobs at the time of installation • This should conform to concurrent processes • Watch this as more workload is migrated to web 10 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 11. Fast CGI • Changing this is something that should be considered But not taken lightly (system resources, etc.) • File to edit: /www/zendsvr/conf/fastcgi.conf SetEnv="PHP_FCGI_CHILDREN=10" • But don’t forget… StartProcesses = “2” * PHP_FCGI_CHILDREN = 8 is 16 total worker jobs http://www.youngiprofessionals.com/wiki/FastCGI http://www.systeminetwork.com/article/other- languages/fastcgi-boosts-php-performance-on-ibm-i-66195 11 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 12. PHP Logs • IFS performance, minimize read/writes Alan will discuss more But what about the logs • Consider the event monitor • Read the logs • Reduce the messages • Clip the log /usr/local/zendsvr/var/log/php.log 12 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 13. Rename the log • Zend Server will create more!  REN OBJ('/usr/local/zendsvr/var/log/php.log') NEWOBJ(phplog20120306.txt) 13 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 14. Extensions • PHP travels with a posse 70+ extensions Many are used every day But if not used, may be turned off… Default, • Zend Server for IBM i shipped with DB2 on and SQL Server off • Look at the Zend Server admin interface – Server setup  Extensions – Like a light switch 14 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 15. IBM i administration • PTF’s Current cumulative & group for HTTP • Memory pools Isolate memory from other attacks • Workload partitioning With i6.1 & i7.1 can protect processor without LPAR • Understanding demands on the systems If the boss doesn’t believe you, have your BP back you up! Performance Monitor tools 3rd party 15 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 16. WRKSYSSTS – The first place to go!!! 16 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 17. Performance Tuning PHP on IBM i www.zend.com Tools © All rights reserved. Zend Technologies, Inc.
  • 18. Firebug add-on graphs performance • Firebug https://addons.mozilla.org/firefox/addon/firebug/ Even better with FirePHP and Page Speed Performance Tuning PHP on IBM i | 18 © All rights reserved. Zend Technologies, Inc.
  • 19. Performance Tuning PHP on IBM i www.zend.com Use Compression © All rights reserved. Zend Technologies, Inc.
  • 20. Compression reduces file size • Called gzip or mod_deflate (the same for our purposes) • Compresses, speeds up html, javascript, css, any text • Add two lines (OK, two long lines) to httpd.conf Apache config  LoadModule deflate_module /QSYS.LIB/QHTTPSVR.LIB/QZSRCORE.SRVPGM  AddOutputFilterByType DEFLATE application/x-httpd-php application/json text/css application/x-javascript application/javascript text/html Performance Tuning PHP on IBM i | 20 © All rights reserved. Zend Technologies, Inc.
  • 21. Netflix saw improvement with gzip/deflate • Saw 13-25% performance improvement • Cut outbound traffic in half That saves money for a busy site such as Netflix • Details of Netflix improvement: http://www.slideshare.net/billwscott/improving-netflix- performance-experience • It really works! • Tutorial on my blog: http://www.alanseiden.com/2010/08/13/maximize-zend- server-performance-with-apache-compression/ Performance Tuning PHP on IBM i | 21 © All rights reserved. Zend Technologies, Inc.
  • 22. Performance Tuning PHP on IBM i www.zend.com Reduce HTTP Requests © All rights reserved. Zend Technologies, Inc.
  • 23. Requests cause “blocking” in browser • Browsers typically limit themselves to 2 parallel requests to a given server • File requests stack up, blocked by prev. requests • • Above, even “not modified” files caused blocking • Solution: reduce number of images or improve caching via “Expires” headers  http://httpd.apache.org/docs/2.0/mod/mod_expires.html Performance Tuning PHP on IBM i | 23 © All rights reserved. Zend Technologies, Inc.
  • 24. More ways to reduce “blocking” • If many .js or .css files are used: Combine them into fewer files Move contents of smaller .js or .css files inline to your pages, eliminating those external files Page Speed tool will help you decide Performance Tuning PHP on IBM i | 24 © All rights reserved. Zend Technologies, Inc.
  • 25. Performance Tuning PHP on IBM i www.zend.com Ajax: friend or foe? © All rights reserved. Zend Technologies, Inc.
  • 26. AJAX=Asynchronous Javascript And XML • AJAX updates parts of a page without reloading the whole page • Not always XML. These days, JSON too • Requests and file sizes are generally small • Meant to bring SPEED to the web • Potential problems if overused Performance Tuning PHP on IBM i | 26 © All rights reserved. Zend Technologies, Inc.
  • 27. AJAX mistake #1 • Too much of a good thing Requiring several AJAX requests to complete before the page itself can load fully Too many HTTP requests at once I’ve seen a situation where 4 AJAX requests were embedded in a page load • The AJAX doesn’t even start till the page loads • Causes “blocking” as the requests pile up, waiting for the previous ones to complete Solution: when page first loads, embed AJAX content right in the page • Re-use logic on the server side when building page • Subsequent updates can be done with AJAX Performance Tuning PHP on IBM i | 27 © All rights reserved. Zend Technologies, Inc.
  • 28. AJAX mistake #2 • Duplicate requests Might go unnoticed with javascript library tools (Dojo, jQuery...) Happens more than you would expect! Common, actually Performance Tuning PHP on IBM i | 28 © All rights reserved. Zend Technologies, Inc.
  • 29. AJAX mistake #3 • Dynamically generating static content (don’t do that) • Solutions: Change to static files Cache URLs (e.g. with Zend Data Cache if using PHP, or Apache caching) See example below, before and after caching Performance Tuning PHP on IBM i | 29 © All rights reserved. Zend Technologies, Inc.
  • 30. Performance Tuning PHP on IBM i www.zend.com Keep-alive © All rights reserved. Zend Technologies, Inc.
  • 31. Keep HTTP connections alive • “Keep-alive” setting in Apache (or any web server) • The HTTP job will stay open, waiting for you Perfect when downloading many images, css, js files • Configurable by number of seconds to keep connection open, number of files to be downloaded KeepAlive On KeepAliveTimeout 15 See http://httpd.apache.org/docs/2.0/mod/core.html#keepalive • Don’t overdo it—you are locking out other users from that HTTP job while it’s dedicated to you Performance Tuning PHP on IBM i | 31 © All rights reserved. Zend Technologies, Inc.
  • 32. Connecting takes time • Clues that Keepalive is off “Connection: close”, “Connecting” • Example bottom right: 3.6 seconds “Connecting” (longer than average but it really happened) Performance Tuning PHP on IBM i | 32 © All rights reserved. Zend Technologies, Inc.
  • 33. What you see when Keep-alive is on • Firebug’s “Net” tab shows “Connection: Keep-Alive”, and, here, timeout=300 seconds (5 minutes) • Zero seconds to connect • Keep-alive is working! Performance Tuning PHP on IBM i | 33 © All rights reserved. Zend Technologies, Inc.
  • 34. Performance Tuning PHP on IBM i www.zend.com Persistent DB Connections © All rights reserved. Zend Technologies, Inc.
  • 35. Persistence = connection pool • On IBM i, job initialization is relatively slow Gives us good things—auditing, logging, security Solution: a pool of pre-initialized jobs • Pre-started DB2 jobs save time Generally run in subsystem QSYSWRK, job name QSQSRVR These prestart jobs can be configured with CHGPJE command • In PHP, persistent connections reuse initialized jobs db2_pconnect() Dramatic speed boost Performance Tuning PHP on IBM i | 35 © All rights reserved. Zend Technologies, Inc.
  • 36. Use db2_pconnect() to connect persistently • resource db2_pconnect ( string $database , string $username , string $password [, array $options ] ) • Persistent is much faster than non-persistent db2_pconnect can reuse connections, reducing the time needed to connect (after the first time) to almost zero • How db2_pconnect() reuses connections Connections defined by database, username, and password Tries to reuse an existing connection matching these 3 params db2_close() on a persistent connection does nothing db2_pclose() forces the conn to close Performance Tuning PHP on IBM i | 36 © All rights reserved. Zend Technologies, Inc.
  • 37. db2_pconnect() example with library list $database = 'MYDB'; $user = 'MYUSER'; $password = 'MYPASS'; // set library list (works the same for connect or pconnect) $options = array('i5_naming' => DB2_I5_NAMING_ON, 'i5_libl' => 'MYLIB1 MYLIB2'); $conn = db2_pconnect($database, $user, $password, $options); if ($conn) { echo "Connection succeeded."; } else { echo "Connection failed."; } // MYTABLE will be found, if in library MYLIB1 or MYLIB2 $stmt=db2_exec($conn,"SELECT * FROM MYTABLE"); Performance Tuning PHP on IBM i | 37 © All rights reserved. Zend Technologies, Inc.
  • 38. Rules for using persistence • Because connections are shared when defined with an identical database, user, and password, please: Avoid unpredictable results by also specifying the same $options for these connections Promote sharing of jobs by minimizing the number of user profiles that you connect with • Each user profile creates a new set of database jobs • Each set of jobs consumes system resources • More information: “DB2 and PHP Best Practices on IBM i” at http://alanseiden.com/presentations Performance Tuning PHP on IBM i | 38 © All rights reserved. Zend Technologies, Inc.
  • 39. New open source PHP IBM i toolkit • Ships with Zend Server 5.6+ PTFs and hotfixes on download page Many improvements since first release • Information and updates: Young i Professionals site • http://youngiprofessionals.com/wiki/XMLSERVICE Zend Forum for Q&A and tips • http://forums.zend.com/viewtopic.php?f=113&t=41648 • “PHP on IBM i”->”Zend Server for IBM i”->”New Toolkit” • Efficient: use single DB2 connection for SQL and Toolkit http://forums.zend.com/viewtopic.php?f=113&t=46688 Persistent connection is the fastest Performance Tuning PHP on IBM i | 39 © All rights reserved. Zend Technologies, Inc.
  • 40. Performance Tuning PHP on IBM i www.zend.com Wrap it up © All rights reserved. Zend Technologies, Inc.
  • 41. Help! • I’ve got PHP applications and not sure what to do? • Do your homework Read, learn, explore Talk in forums (Zend.com and midrange.com) • Zend Services Application Audit • Up to 50,000 lines of code • Review on site or off (knowledge transfer!) • Report summary & remediation available 41 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 42. Zend Performance Audit  Comprehensive Methodology  Detailed evaluation of your application and environment  Detailed analysis of performance patterns and behaviors  Provide report and improvements recommendations  Proven Success  Delivered to numerous Global 1000 companies  Accelerated performance across industries  Methodologies applied to hundreds of applications  Delivered by the PHP Company Experts  Unparalleled experience in PHP and Zend Server  Methodology developed by the architects of PHP  Utilizing Zend standard benchmarks 42 Zend Professional Services © All rights reserved. Zend Technologies, Inc.
  • 43. Zend Server features (Full version) • Event Monitor Become aware of issues before your users call • Code Tracing Black box flight recorder for PHP scripts • Caching Op-code (Alan discussed & available with CE) Data (Also available with CE) Page • Job Queue SBMJOB for PHP!!! 43 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 44. Webcasts • April 12 – Stored Procedures Part II (RPG, etc.) • May 2 – Additional Functions of DB2 with PHP on IBM i Your thoughts??? 44 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 45. Events where you’ll find Zend… • User groups WMCPA (Lake Geneva, WI) Mar 20-22 (Mike & Alan) • http://wmcpa.org/ NEUGC (Boston, MA) April 2-4 • http://neugc.org/ Alan: March 29: COMMON webcast: more performance tips http://www.common.org/index.php/webcasts/upcoming-webcasts.html April 5: live online event with System i Network New PHP Toolkit for IBM i http://www.systeminetwork.com/events/upcoming-events In New York City? I host the NYC Zend Framework Meetup http://www.meetup.com/ZendFramework-NYCmetro/ 45 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 46. Events where you’ll find Zend…(cont.) • Major venues RPG & DB2 Summit (Ft. Worth, TX) Mar 25-28 • http://www.systemideveloper.com/Summit/conferences.html COMMON Annual Meeting and Expo (Anaheim, CA) May 6-9 • http://www.common.org/index.php/annualmeeting.html COMMON Fall Conference (Columbus, OH) Sep 24-26 • http://www.common.org/index.php/fall-conference-and-expo.html 46 Insert->Header & Footer © All rights reserved. Zend Technologies, Inc.
  • 47. Contact | Get tips Alan Seiden Strategic Business Systems, Inc, 201-327-9400 17 S. Franklin Tpk aseiden@sbsusa.com Ramsey, NJ, 07446 http://alanseiden.com Twitter: @alanseiden Free PHP/i tips by email: http://alanseiden.com/tips Performance Tuning PHP on IBM i | 47 © All rights reserved. Zend Technologies, Inc.
  • 48. Q&A mike.p@zend.com aseiden@sbsusa.com Watch the recorded webinar: http://bit.ly/A4NjYM 48 © All rights reserved. Zend Technologies, Inc.