Why is sylius running so slow on local in dev?

99封情书 提交于 2019-12-03 01:36:54
Kirill Fuchs

First let me thank @Florian for his link and the nudge to get me digging a little :).

When following the instructions on sylius' getting started page:

$ wget http://getcomposer.org/composer.phar
$ composer.phar create-project sylius/sylius -s dev
$ cd sylius
$ app/console sylius:install

you are by default installing using the config_dev.yml file. This will setup your db as {dbname}_dev, as well as have debug on in app_dev.php. When debug is on "cache files are dynamically rebuilt on each request." This is what is causing the slow speed.

In regards to using app.php(production env) you can run app/console sylius:install -e prod. This will setup a regular db and you can use app.php.

Mystery solved :).

Useful resource: How to Master and Create new Environments - Symfony2

Oggy

If you are on windows make sure to set your "realpath_cache_size" to at least 5M in your php.ini, as recommended by the SensioDistributionBundle. Like so:

; php.ini

realpath_cache_size = 5M

On my Sylius installation running in dev environment it reduced load times from ~15 s to ~2 s.

To further reduce your load times you might consider using WinCache https://sourceforge.net/projects/wincache/. I use the following settings while running Sylius with PHP's inbuilt web server:

; php.ini

[wincache]

wincache.enablecli=1

wincache.filecount=16384

WinCache seems to work just fine with Sylius's dev environment.

Sylius much slower then Symfony both in production and development mode although it is built on top of Symfony. The reason is its ResourceBundle. I'm sure there are methods to accelerate it in production but anyway it is very slow while development.

I was running Sylius on a Vagrant setup with default sync folder settings and found it extremely slow, up to 45 sec loads! Other Small Symfony projects weren't as bad so thought it was just Sylius, then I read that the synched folder settings on Vagrant are a lot quicker with the type NFS available on linux systems, it reduced from 40 to 4 seconds!

So if you're using Vagrant and find it slow make sure you set sync folders to NFS.

NFS will help you in vagrant case but still you can find it slow in bigger projects. Docker was even worse on MACOSX. If you are using Linux I think docker will kick ass for developemnt. Also if you are using PHP<7 move to 7.0 (upper versions have some issues with Sylius atm) and you will see huge improvement of performance even in dev enviroment.

Also give some more RAM to your Vagrant machine

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!