Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does it make sense to remove PHP extension which I do not use?

I am not very sure whether it is better suited here or on ServerFault, so please feel free to move it, if needed. I just posted it here because I think it is highly relevant to PHP programmers and more people might be able to help me.

I run PHP application on apache server under Ubuntu. Few days ago I looked into phpinfo() and found out that I only use a few of the majority of extensions that are installed and enabled. The list of not used extensions is huge (there is a small chance that some of them I need, but this is easy to determine and enable if so). So among other things there are (explanation of what these things are doing is approximate. It is super easy to find precise description):

  • bcmath (arbitrary calculation precision)
  • bz2, zip, zlib, phar (archivators)
  • dba, PDO (handling databases)
  • libXML, simpleXML, XML, XMLReader, XMLWriter, DOM (so many things for handling XML)
  • ereg (regular expression. Deprecated long time ago)
  • FTP
  • gettext (internationalize php application)
  • readline (something about command line)
  • reflection (ability to reverse engineer classes, interfaces)
  • SOAP (write SOAP service/client)
  • sysvshm, wddx (no idea)

As you see, the list is huge. I am using Mongo as a storage and all my communication with a server is through ajax (JSON), so I highly doubt I need XML/Dba/SOAP/ftp now or in the near future.

So before going and trying to disable each of them one by one and checking if my app still works, I wanted to ask: does it makes sense to disable them? I know that disabling unneeded modules from apache can give a reasonable boost in productivity of the server, but I have not found any normal tests/calculations of this kind about PHP.

So my question can be better stated in this way: does anyone have done some tests to find out what improvements will I gain from disabling/removing unneeded modules (speed, memory consumption and so on). Please refrain from posting something like 'sure it make sense - remove them', or 'do not remove - you can break something' or even citing 'premature optimization is ...'.

like image 470
Salvador Dali Avatar asked Nov 01 '22 01:11

Salvador Dali


1 Answers

Not really.
Disabling modules will only reduce the footprint of each Apache+PHP instance. This can give you a boost indeed, but only at high loads / heavy traffic. As far as process starting / context switching is not a major bottleneck, you're safe with all your modules enabled.

Then again...
A very clear exception is xdebug. It's not really a module but if you leave it on, it's gonna cost you around 200-400ms per request. Big numbers, especially since Google started rewarding fast(er) sites. Debuggers and profiles must be OFF for production.

like image 114
dkellner Avatar answered Nov 13 '22 18:11

dkellner