Home  >  Article  >  Backend Development  >  About Yii's method to improve the performance optimization of concurrent numbers

About Yii's method to improve the performance optimization of concurrent numbers

不言
不言Original
2018-07-10 15:28:252832browse

This article mainly introduces the performance optimization method of Yii to improve the number of concurrency. It has a certain reference value. Now I share it with you. Friends in need can refer to it

  1. Turn on YII's APC cache

  • Add under the config/main.php components component:

     'apccache'=>array(
                'class'=>'system.caching.CApcCache'
          ),
  • Download php_apc.dll, file Put it under php/ext, it may be more troublesome to search....

  • Add the php_apc extension in php.ini:

     extension=php_apc.dll
     apc.rfc1867 = on
     capc.max_file_size = 100M
     upload_max_filesize = 100M
     post_max_size = 100M

    Restart apache, use Function info(), check whether there is apc extension.

  • Usage:

        Yii::app()->apccache->get(id);
        Yii::app()->apccache->set(id,value,time);

2. Use yiilite.php
Import yii.php into the entry file index.php , change to introduce yiilite.php

<?php
    error_reporting(E_ERROR);
    $config = dirname(__FILE__) . &#39;/protected/config/main.php&#39;;
    defined(&#39;YII_DEBUG&#39;) or define(&#39;YII_DEBUG&#39;, false);
    defined(&#39;YII_TRACE_LEVEL&#39;) or define(&#39;YII_TRACE_LEVEL&#39;, 3);
    //require_once &#39;../../xq_cgi-yii/framework/yii.php&#39;;
    require_once &#39;../../xq_cgi-yii/framework/yiilite.php&#39;;
    Yii::createWebApplication($config)->run();

Note:

  • Open apc cache and then introduce yiilite.php, because there are some classes in this file that are not currently used will also be loaded in.

  • If apc cache is not turned on, website performance will be reduced.

The above is the entire content of this article. I hope it will be helpful to everyone’s study. For more related content, please pay attention to the PHP Chinese website!

Related recommendations:

yii2’s preventive measures against csrf attacks

The above is the detailed content of About Yii's method to improve the performance optimization of concurrent numbers. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn