Why is CakePHP 3 loading classes in a Vagrant box so slowly?

Customization

  • Wandering Box (2 GB of memory)
  • Apache / 2.2.22 (Ubuntu)
  • PHP 5.4.38-1 + deb.sury.org ~ exact + 2 (cli) (built: February 20, 2015 12:16:47)
  • CakePHP 3

I just installed the new CakePHP 3 with the composer, and with the most basic default home page, I noticed that the page loaded, like 4 loaded from ~ 5. Here are the tests ( kitchen.com is the server alias):

Chrome Dev Tools

enter image description here

Phpstorm + xdebug

enter image description here


Even composer.phar dumpautoload -o n't changed anything.


Sometimes some REST calls (returning small json) can reach ~ 12 s due to startup and this php_sapl_name:

AJAX REST call

 { "settings": { "sitename": "Site settings", "desciption": "Lorem ipsum" } } 
  • Controller action:
 public function index() { $this->set('settings', ['sitename' => 'Site settings', 'desciption' => 'Lorem ipsum']); $this->set('_serialize', ['settings']); } 

Chrome dev and PhpStorm + Xdebug tools

enter image description here

enter image description here


So is this a common error on CakePHP 3, or can it come from my server configuration?

+5
source share
1 answer

You must ensure that you have caching operation code enabled. In general, PHP performance suffers severely without caching operation code.

Also make sure your computer is not limited in terms of I / O performance. Since PHP applications need to upload multiple files for each request, IO on disk matters.

I would say that the results are very far from typical. I usually get responses from baked code at <150ms on my 2 year old laptop from CakePHP.

Edit: I am re-reading your question and notice that you are using VM. Shared VM file systems are notoriously slow. If you are sharing with the host in the guest OS, see if the performance has improved by moving the code from the shared file system.

+4
source

All Articles