PHP performance tip: disable unused extensions with Zend Server

Whenever I’m brought in to improve the performance of a PHP application, an easy change I make is to disable any PHP extensions that the application does not use. PHP extensions are code libraries written in C that add to PHP’s native functionality. Examples of popular extensions on IBM i are ibm_db2 and curl.

Boost performance by disabling unneeded extensions

I’ve noticed that Zend Server ships with most extensions enabled, presumably so that developers won’t have to see “extension not enabled” error messages. While the default configuration is fine as a starting point, developers should understand that each extension requires memory when loaded. When every bit of performance counts, it’s best to disable the unused extensions. Note: don’t disable anything till you read Several Extensions to Keep Enabled.

Managing PHP extensions

To manage extensions, Zend Server provides the “Server Setup / Extensions” tab. Each extension can be enabled or disabled with its “Turn on” or “Turn off” links. Changes do not take effect until the “Restart PHP” button is clicked.

Zend Server PHP extensions management page

Zend Server's Extensions page where PHP extensions are managed

Storage location for extension settings

Zend Server stores extension settings in a set of .INI files, one file per extension. On IBM i, the files are located in /usr/local/ZendSvr/etc/conf.d. Before making large-scale changes, you may wish to back up this folder. Then, if you discover you were overzealous in disabling extensions, you can compare the contents of conf.d with your backup to find out where you went wrong.

Several extensions to keep enabled

In addition to whatever extensions are required by a given application, I’ve found that several extensions are required by Zend Server itself. Do not disable these. So far, I’ve found that Zend Server requires these extensions to be enabled:

  • ctype
  • iconv
  • json
  • pdo_mysql
  • simplexml (used by new open source toolkit)
  • zip

If you accidentally disable an extension required by Zend Server, which you’ll discover when Zend Server fails to start properly, you must re-enable the extension in the correct .INI file and then restart Zend Server from a command line or menu. On IBM i, the command is STRTCPSVR SERVER(*HTTP) RESTART(*HTTP) HTTPSVR(ZENDSVR).

More performance tips to come

I plan to write about more techniques to improve PHP application performance, particularly on IBM i, that I’ve found to be effective in my consulting experience. Performance is a critical part of user experience that developers should not ignore. In addition to this practical need for good performance, I can speak for myself, at least, in saying I feel great satisfaction when I can take a slow application (sometimes the victim of an underpowered server) and, step by step, help it run faster and faster, till the performance is at least acceptable and sometimes quite fast. More to come.

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.