Yii Tuning To Run On A Network Share

First of all I am happy to see that Yii2 is at beta release which i have been waiting for a long time for this and thanks

I am looking at the basic and advanced template and want to dig deeper with the advanced template. I do a stopwatch on each click to compare how Yii perform when it run entirely on a network share to Yii load the vendor from a local hard drive to see the different on performance.

Entire Yii on network share:

login: 12:10’

contact: 6.95’

about: 6.05’

Yii on network with vendor on local hard drive:

login: 7.58’

contact: 4.13’

about: 4.31’

As you can see there is some performance gain when point the “vendor” folder to a local hard drive but I want it to be a little faster so I start looking around and see some potential such as “assets” and “runtime” folder which is being use for “caching”, “debug” and “logs” but I don’t see any easy way to point these folders to a local hard drive away from where Yii is running from.

I have a need to run Yii from a network share for many reasons.

Is it possible to do that with these folder?

PS: My goal is to have the time on each click down to less then 4’

Thanks

You can configure runtimePath from main level of application config. Assets is configured as ‘components’ => [‘assetManager’ => [‘basePath’ => ‘xxx’]].

By point “assests” folder to a local hard drive, that cut down the time to less than 3’ but it turns out not a desirable change because it mess up the css path and cause it not to show the layout correctly.

How about the "runtime" folder under frontend and backend?

Can that being point to some where else?

Will that help to speed up thing?

Are there any place else that can be move to tune thing up a little more?

Thanks

I add this line in the main.php for frontend and backend and it does cut down the load time to less then 3’-4.4’ which is excellent!

'runtimePath' => YIISOFT . '/../../runtime/frontend',

But the login time is still too long! It took 7.5’ just to login.

Is there any way to turn that down a little?

Thanks

That depends very much on your environment and code so can’t say anything. Profile it, find bottlenecks, fix it. If it’s anything about the framework itself, tell us and we’ll work on it.

It is a stock install of Yii with the advanced template.

The only thing I changes are just point the vendor and runtime folder to a local hard drive and test the timing of frontend and backend by clicking on the each link and the login

What you recommend the best way to profile Yii?

Would Xdebug work?

Thanks

For the sake of a baseline comparison, I run Yii from a local hard drive and test the timing of login and it took 6.1’ just to login and compare to running from the network which is 7.5’ so it is something about Yii2 that taking sometime to do database operation.

5518

yii2xdebug.zip
Attached is the profiles that collected by xdebug when I click on login so you can see what is going on with Yii.

Thanks

For me it takes about 765ms to login using database. Most of the time it’s crypt call that is meant to be kinda slow so it’s secure.

You’ve attached 2 profiling dumps. In the one about login crypt still takes quite some time but connecting to database takes almost the same time and that’s definitely wrong. Also autoloading seems to be kinda slow in your case. I suggest:

  1. To check why database connection is slow. Is it local server? Do you have localhost in DSN? Is it resolving fast and w/o errors?

  2. Do you have APC or Opcache installed? Is framework itself and application code are on the local FS?

  1. It is Windows 2012 R2 with MySQL 5.5 install locally. the localhost resolving fast without any problem.

  2. I have no cache install. I copy the entire advanced template to network share and make these change in frontend/web and backend/web respectively

I create a site that point to the above network share that store the advanced template and run Yii from there

Frontend/web/index.php

defined(‘YIISOFT’) or define(‘YIISOFT’, ‘G:\yii2\vendor\yiisoft’ );

require(YIISOFT . ‘/../../vendor/autoload.php’);

require(YIISOFT . ‘/../../vendor/yiisoft/yii2/Yii.php’);

backend/web/index.php

defined(‘YIISOFT’) or define(‘YIISOFT’, ‘G:\yii2\vendor\yiisoft’ );

require(YIISOFT . ‘/../../vendor/autoload.php’);

require(YIISOFT . ‘/../../vendor/yiisoft/yii2/Yii.php’);

I create folder on local G drive where I put the entire "vendor" folder and create the runtime to store the frontend and backend runtime.

G:\yii2

Thanks for your time.

  1. According to profiling connecting to MySQL is extremely slow. I’m running MariaDB on Windows 8 and it’s much faster.

  2. Try APC (if your PHP is <5.5) or Opcache (if PHP>=5.5).

  3. Network share is a bad idea according to profiling. Slows down class loading significantly but APC/Opcache may make it better.

  1. Are you using 64 bits or 32 bits?

  2. I will see what I can do about cache.

  3. I need the security context of running from the network share and auto backup of the SAN, etc.

Thanks

unfortunately, those two cache options are not for Windows

I install Wincache with opcache and filecache enabled and the network login is now down to 6.57’ and the local login is now 5.61’

It is much better then 7.5 and 6.1 but it would be nice it it can be faster.

Thanks

Just upgrade mysql to 5.6 and with the Wincache enabled here is the new timing for the login:

local: 3.77

network: 4.68

That is much better.

Thanks

I’m using x64. Everything works via php-fpm and nginx.

More things to consider:

  1. If you’re on IIS make sure you’re using fastcgi: http://www.iis.net/downloads/microsoft/fastcgi-for-iis

  2. Make sure you’re using nts (non thread safe) builds.

I do use IIS and fastCGI

I heard that nginx is very fast web proxy but it can only work with local file not like IIS can serve up a web site hosted on a network share and support Windows integrated security, etc.

I will find out little more about php-fpm

Thanks