Home>Article>Backend Development> Asf PHP development configuration information is resident in system memory

Asf PHP development configuration information is resident in system memory

不言
不言 Original
2018-07-07 16:48:26 1381browse

This article mainly introduces the configuration information of Asf PHP development resident in the system memory. It has a certain reference value. Now I share it with you. Friends in need can refer to it.

Comparison between traditional MVC and Asf

Traditional MVC framework

The configuration file will be reloaded with each request. Even if the configuration file content has not been updated, it will be reloaded. This is a very bad design. (When Opcache is turned on, there is still execution time)

Asf framework

The content of the read configuration file is saved to the system memory, and the next request goes directly to the memory to read the data. Asf also provides a very simple configuration implementation Config Cache.

In what scenarios is it appropriate to enable Config Cache?

  • It is recommended to enable it in web application scenarios. Later versions may enable it by default

  • It also takes effect when enabled in CLI and multi-threaded mode, but the PHP script is released every time it is executed.

  • ##Supported data types are: strings, arrays, integers, boolean, doubles, floats, null

Flowchart

Asf PHP development configuration information is resident in system memory

Enable caching method

Frame entry way to load php/ ini configuration file

run();

Asf\Config\Php Load php configuration file

Asf\Config\Ini Load ini configuration file

Read configuration content method

getConfig()->toArray()); print_r(Asf\Config::get()->toArray());

Performance test

With Opcache turned on, we simply did a Config Cache performance test, ab -c100 -n10000

There is a difference between the complexity of the configuration items in the configuration file and the performance indicators. Contact us directly

Enable cache asf.cache_config_enable = 1

Total transferred: 16109994 bytes HTML transferred: 14259994 bytes Requests per second: 6859.01 [#/sec] (mean) Time per request: 14.579 [ms] (mean) Time per request: 0.146 [ms] (mean, across all concurrent requests)

No cache

Total transferred: 16080000 bytes HTML transferred: 14230000 bytes Requests per second: 6398.22 [#/sec] (mean) Time per request: 15.629 [ms] (mean) Time per request: 0.156 [ms] (mean, across all concurrent requests)

Tips

Cache Config is not based on shared memory, it is based on For PHP processes, there will be no problem with shared memory locks.

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:

Nginx load scheduler dual Tomcat load and session sharing MySQL back-end database

ThinkPHP5.0 Linux Apache/ Nginx rewrite URL configuration

The above is the detailed content of Asf PHP development configuration information is resident in system memory. 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