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
<?php 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:
No matter how many business applications are expanded, only one configuration center is needed to complete multiple configuration modifications.