I would like to ask the PHP project common configuration, how everyone is handled.

Source: Internet
Author: User
First of all, thank you.

I would like to ask you in your own project is how to deal with the configuration file.

For example, I now have a key=>value configuration, about 1200 or so. I use the YII2 framework.

Every time the framework starts, it loads all the profiles because it's much more. So a little worried about the project will be a problem after the official launch. For example, there are many people online. This is more configuration, each time the memory consumption will be relatively large.

How do you deal with this, please?

    1. Put it in the configuration.

    2. Cache

    3. Database

    4. ???

My project is officially on-line, with an estimated online spikes of less than 1k users.

Please share a better solution. Thank you.

Reply content:

First of all, thank you.

I would like to ask you in your own project is how to deal with the configuration file.

For example, I now have a key=>value configuration, about 1200 or so. I use the YII2 framework.

Every time the framework starts, it loads all the profiles because it's much more. So a little worried about the project will be a problem after the official launch. For example, there are many people online. This is more configuration, each time the memory consumption will be relatively large.

How do you deal with this, please?

    1. Put it in the configuration.

    2. Cache

    3. Database

    4. ???

My project is officially on-line, with an estimated online spikes of less than 1k users.

Please share a better solution. Thank you.

Configuration items are very much, if the system performance requirements are relatively high, it is recommended to use the Redis cache, and then add a background page to dynamically manage these configuration items, in addition, it is recommended to group configuration items, such as pre-load configuration, lazy load configuration, Other modules to use but the current module does not require the configuration of the group to differentiate, what needs to load what, in addition to the development environment, test environment, formal environment and other dimensions of the grouping, finally, in order to reduce the problem of Redis failure caused by error, it is recommended to put the system default configuration in the file, And make an error reminder, so-called downgrade use.

Yac you deserve to have

Configuration files are stored separately, such as:

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

Then write a class library on demand lazyload load, asConfig::get('db.user_name');

I think you are worried, under your traffic volume, loading this configuration file is not a problem, especially after opening PHP Opcache

You can do the stress test with the AB test.

Laruence's Yac, you can think about it.

Thank you so much. It seems that the specific situation should be specifically treated.

  • Related Article

    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.