We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Speeding up Composer autoload

I load two libraries via composer: aws-sdk-php and azure-sdk-for-php. By only loading those libraries I slow down my application's RPS almost by 50%. I don't event instantiate those libraries in my code. They are only loaded by:

require __DIR__ . '/../vendor/autoload.php';

Results with Composer libraries

$ ab -n 1000 -c 50 https://127.0.0.1
Requests per second: 813.27 [#/sec] (mean)

Results without Composer libraries:

$ ab -n 1000 -c 50 https://127.0.0.1
Requests per second: 1509.20 [#/sec] (mean)

Is there any way to speed things up but still use libraries available in Composer or do I simply need to live with this performance decrease?



98.9k
Accepted
answer

Perfect, thanks. After upgrading to PHP 5.5.14 and enabling opcache I was able to speed things up drasticaly:

$ ab -n 1000 -c 50 https://127.0.0.1
Requests per second: 2101.23 [#/sec] (mean)
edited Jan '15

You can also use this command in Composer (should increase it a bit more):

--optimize-autoloader (-o): Convert PSR-0/4 autoloading to classmap to get a faster autoloader. This is recommended especially for production, but can take a bit of time to run so it is currently not done by default.