I would like to ask you how to deal with common configurations in the php project.

Source: Internet
Author: User
First of all, thank you. how do you handle configuration files in your project. for example, I have a key & amp; gt; value configuration, about 1200. I use the yii2 framework. every time the framework starts, all configuration files will be loaded, because there are too many. so I am a little worried about the project... first of all, thank you.

How do you handle configuration files in your project.

For example, I now have a key => value configuration, which is about 1200. I use the yii2 framework.

Every time the framework starts, all configuration files will be loaded, because there are too many. so I am a little worried about problems after the project is officially launched. for example, the number of online users is too large. with such a large number of configurations, will the memory consumed each time be relatively large.

What do you do?

  1. Put it in configuration

  2. Cache

  3. Database

  4. ???

My project was officially launched, with an estimated peak value of less than 1 K at the same time.

Please share with us some better solutions. Thank you.

Reply content:

First of all, thank you.

How do you handle configuration files in your project.

For example, I now have a key => value configuration, which is about 1200. I use the yii2 framework.

Every time the framework starts, all configuration files will be loaded, because there are too many. so I am a little worried about problems after the project is officially launched. for example, the number of online users is too large. with such a large number of configurations, will the memory consumed each time be relatively large.

What do you do?

  1. Put it in configuration

  2. Cache

  3. Database

  4. ???

My project was officially launched, with an estimated peak value of less than 1 K at the same time.

Please share with us some better solutions. Thank you.

There are a lot of configuration items. If the system performance requirements are relatively high, we suggest using the redis cache method, and then you can add a background page to dynamically manage these configuration items. In addition, we recommend that you group configuration items, such as pre-loaded configurations and lazy configuration. You can use configurations that are not required by the current module in other modules for grouping and differentiation. you can load configuration items as needed, in addition, you can also group data by dimensions such as the development environment, test environment, and formal environment. Finally, to reduce errors caused by redis faults, we recommend that you put the default configuration in the file, and make an error message, the so-called downgrade.

Yac you deserve

The configuration file is stored separately, for example:

db.conf.phpftp.conf.phpcache.conf.php

Then write a class library and load the class library as needed, as shown in figureConfig::get('db.user_name');

I think you have considered it too much. loading this configuration file is not a problem with your traffic volume, especially after you enable the php opcache.

You can use the AB test to perform a stress test.

For Laruence Yac, consider

Thank you for your consideration.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.