• The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
Menu
  • The Four Hundred
  • Subscribe
  • Media Kit
  • Contributors
  • About Us
  • Contact
  • Guru: Right-Size Your PHP

    December 3, 2018 Alan Seiden

    In my experience doing performance audits, I often point out that while PHP for IBM i comes perfectly configured for small applications, it must often be tuned to handle large workloads. When applications must accommodate hundreds or thousands of users, or use AJAX technology, two easy changes should be considered for PHP and Apache configurations.

    1. PHP_FCGI_CHILDREN Setting In fastcgi.conf

    On IBM i, Zend Server installs a configuration file called fastcgi.conf. Among other settings, it includes PHP_FCGI_CHILDREN, which determines how many PHP jobs run when its Apache server is started. The file — /www/zendphp7/conf/fastcgi.conf (Zend Server 9 or higher) or /www/zendsvr6/conf/fastcgi.conf (Zend Server 6, 7, 8, or 8.5) — includes the following setting:

    SetEnv="PHP_FCGI_CHILDREN=10"
    

    The above setting specifies that there should be 10 PHP jobs to handle incoming. While this number is acceptable when requests run and finish quickly with moderate workload, it may be too small when some requests run slowly (from slow queries and the like) or to accommodate high numbers of users or AJAX requests (AJAX causes multiple PHP requests per page to run).

    How to find the best setting? At Seiden Group, we run special monitoring code to measure workload throughout the day, but you can take a sample by looking at WRKACTJOB and seeing how many PHP jobs (named ZENDPHP7 or ZENDSVR6) have a job status other than TIMW.

    Example of an “idle” (waiting for work) PHP job:

    ZENDSVR6     QTMHHTTP    BCI      .0  PGM-php-cgi.bi   TIMW
    

    Rogue Wave’s Rod Flohr has written a detailed article about how to increase FastCGI child processes for PHP. In a nutshell, we edit the fastcgi.conf file to increase the number of child processes. I use something like Zend Studio or even WRKLNK to edit the file.

    Look for this:

    SetEnv="PHP_FCGI_CHILDREN=10"
    

    Set the number to the number of processes you want. For example, to set it to 25, change it to this:

    SetEnv="PHP_FCGI_CHILDREN=25"
    

    Be sure that this line in the configuration remains all on one line. Save and exit.

    Restart Apache for this change to take effect.

    I suggest making modest changes because increasing the processes too abruptly may allow in more workload than you really want to run at one time. Performance issues may indicate other issues to resolve, such as queries that need optimization or to address PHP session locking (a common issue with AJAX), examples of issues that may be addressed in a full performance audit.

    2. ThreadsPerChild Setting In Apache Configuration httpd.conf

    Apache provides further controls over site traffic. The ThreadsPerChild directive controls the maximum number of simultaneous HTTP connections. Defaulting to 40, ThreadsPerChild’s limit will include not only PHP scripts, but all file requests, including cascading style sheets (CSS), JavaScript, and images.

    The httpd.conf file can be edited directly in /www/zendphp7/conf/httpd.conf (or in zendsrv6 for older versions of PHP), or using IBM’s HTTP configuration administration site at port 2001, which requires starting the *ADMIN web instance. You can find more details here.

    If you see a value for ThreadsPerChild, such as:

    ThreadsPerChild 40
    

    Then you can increase the 40 to something higher.

    If you see no value at all then you may add the directive yourself. To set a value of 100, you could add:

    ThreadsPerChild 100
    

    How to determine the best ThreadsPerChild value? Look at the “real-time server statistics” area on the HTTP Admin page (from port 2001 as specified earlier) during an active time for your site, and see how many Active Threads and Idle Threads are shown. If you have plenty of Idle Threads then you are doing fine, but if there are zero Idle Threads, or even worse, a number in the billions (indicating a negative number), you’ll want to increase ThreadsPerChild.

    For additional information, see this link on the Seiden Group website.

    PHP Has Hit The Big Time On IBM i

    IBM i shops have gone far beyond “kicking the tires” with PHP. This open source language is at the heart of many mission-critical production applications that have grown over time.

    In my experience doing performance audits, I’ve found that the PHP_FCGI_CHILDREN and ThreadsPerChild settings are often either overlooked, or increased too much. Setting the optimal values (like the porridge in the Three Little Bears, not too hot, not too cold, but just right), can make the difference when configuring PHP on IBM i for excellent performance.

    An IBM Champion and founder of Seiden Group, Alan Seiden leads a team that mentors clients in building APIs and web/mobile applications using open source, PHP, Python, Node.js, and IBM i business logic. Alan’s passion for the IBM i community inspires him to host the bi-annual CIO Summit and offer a free monthly tips newsletter.

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Tags: Tags: 400guru, AJAX, Apache, cascading style sheets, CSS, FHG, Four Hundred Guru, IBM i, JavaScript, PHP, PHP on IBM i, Zend

    Sponsored by
    DRV Tech

    Get More Out of Your IBM i

    With soaring costs, operational data is more critical than ever. IBM shops need faster, easier ways to distribute IBM applications-based data to users more efficiently, no matter where they are.

    The Problem:

    For Users, IBM Data Can Be Difficult to Get To

    IBM Applications generate reports as spooled files, originally designed to be printed. Often those reports are packed together with so much data it makes them difficult to read. Add to that hardcopy is a pain to distribute. User-friendly formats like Excel and PDF are better, offering sorting, searching, and easy portability but getting IBM reports into these formats can be tricky without the right tools.

    The Solution:

    IBM i Reports can easily be converted to easy to read and share formats like Excel and PDF and Delivered by Email

    Converting IBM i, iSeries, and AS400 reports into Excel and PDF is now a lot easier with SpoolFlex software by DRV Tech.  If you or your users are still doing this manually, think how much time is wasted dragging and reformatting to make a report readable. How much time would be saved if they were automatically formatted correctly and delivered to one or multiple recipients.

    SpoolFlex converts spooled files to Excel and PDF, automatically emailing them, and saving copies to network shared folders. SpoolFlex converts complex reports to Excel, removing unwanted headers, splitting large reports out for individual recipients, and delivering to users whether they are at the office or working from home.

    Watch our 2-minute video and see DRV’s powerful SpoolFlex software can solve your file conversion challenges.

    Watch Video

    DRV Tech

    www.drvtech.com

    866.378.3366

    Share this:

    • Reddit
    • Facebook
    • LinkedIn
    • Twitter
    • Email

    Mad Dog 21/21: The Fake, The Take, But In The End Jake What Is The State Of Your IBM i Modernization?

    Leave a Reply Cancel reply

TFH Volume: 28 Issue: 80

This Issue Sponsored By

  • UCG Technologies
  • ProData Computer Services
  • ARCAD Software
  • Computer Keyes
  • Manta Technologies

Table of Contents

  • Goosing Big Iron Power Systems With Power9 Migrations
  • What Is The State Of Your IBM i Modernization?
  • Guru: Right-Size Your PHP
  • Mad Dog 21/21: The Fake, The Take, But In The End Jake
  • Some Insight Into The IBM i On Power Systems Base

Content archive

  • The Four Hundred
  • Four Hundred Stuff
  • Four Hundred Guru

Recent Posts

  • Meet The Next Gen Of IBMers Helping To Build IBM i
  • Looks Like IBM Is Building A Linux-Like PASE For IBM i After All
  • Will Independent IBM i Clouds Survive PowerVS?
  • Now, IBM Is Jacking Up Hardware Maintenance Prices
  • IBM i PTF Guide, Volume 27, Number 24
  • Big Blue Raises IBM i License Transfer Fees, Other Prices
  • Keep The IBM i Youth Movement Going With More Training, Better Tools
  • Remain Begins Migrating DevOps Tools To VS Code
  • IBM Readies LTO-10 Tape Drives And Libraries
  • IBM i PTF Guide, Volume 27, Number 23

Subscribe

To get news from IT Jungle sent to your inbox every week, subscribe to our newsletter.

Pages

  • About Us
  • Contact
  • Contributors
  • Four Hundred Monitor
  • IBM i PTF Guide
  • Media Kit
  • Subscribe

Search

Copyright © 2025 IT Jungle