I have a server which consists of several Zend Framework application.
I want to know if it is a good idea to upload Zend Library on the server and share it among all the applications instead of uploading it per application.
Does it influence speed if for example multiple applications request a library simultaneously or not.
What is its Pros and Cons?
Thx in advance.
My answer applies in general to shared libraries, as this should not be specific to Zend Library:
PROS of sharing:
CONS of sharing:
As others have pointed out, there are pros and cons. The big con is that every time you're going to upgrade your library code, you need to test every application, not just the one that needs the upgrade right now.
The big pro is that if you're using an opcode cache like APC (and you should be), you're wasting a fair bit of memory loading identical chunks of library code. Depending on the size of your opcode cache, and how much of the library code actually ever gets run, this could become an issue at some point. If the size of your opcode cache is not big enough to hold everything, you'll end up with a performance hit of some magnitude.
A middle-ground solution is to keep all your libraries some place on the server where they can be shared. Build your apps to use some configuration value for loading.
APP1: config.php
<?PHP
define('ZEND_LIB_PATH','/path/to/ZendFramework-1.9/library');
set_include_path(ZEND_LIB_PATH . PATH_SEPERATOR . get_include_path());
APP2: config.php
define('ZEND_LIB_PATH','/path/to/ZendFramework-1.10.1/library');
set_include_path(ZEND_LIB_PATH . PATH_SEPERATOR . get_include_path());
That way if two apps happen to be using the same version, they can share opcode caches for that version, but you're not tied to it.
DISCLAIMER: I haven't actually done this, so you probably want to test the theory before putting it into practice.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With