Fastd best practice 2: building configuration center


In the past, we made a document to build the configuration centerzookeeperConfiguration center.

For environmental requirements and construction steps, please refer to:Qconf builds configuration center

With the growth of business, the number of deployed machines may grow, which will increase the difficulty of configuration and maintenance. Configuration will become more error prone because of the increase of machines. In order to solve this problem, we introduced qconf developed by 360 to solve this problem, which has been stably used in the online environment.

Install the qconf expansion pack

composer require fastd/qconf-service-provider -vvv

The expansion package is a bit special, and does not need any registration operation. After the composer dependency is executed, the auxiliary function will be loaded automatically. You only need to read and configure the configuration center.

Two functions are provided:

qconf_get_valueGet the corresponding node value

qconf_get_valuesGet the corresponding node value array

Modify configuration file



return [
    'demo' => qconf_get_value('/demo/test', null, null, 'abc')

It is worth noting that if you are not careful, if qconf fails to run due to errors or exceptions, you need to keep a default configuration item. This small action may save your life when your system is abnormal.

Test configuration center

After completing the basic configuration, we need to test the configuration center.

php bin/console config:dump config

As a result, the configuration file will be output to confirm whether it is available.

The final architecture is as follows:

Fastd best practice 2: building configuration center

No matter how many business applications are expanded, only one configuration center is needed to complete multiple configuration modifications.

Recommended Today

Vue practice (V) – deep component dependency injection / event bus (component loose coupling)

0. Background As we all know, the communication between components, especially the data transfer between parent and child components, is carried out through props attribute.In fact, in addition to this method, we have other alternative methods, which we call dependency injection.Dependency injection eliminates the need for tight coupling between components.In addition, we also have an […]