The Configuration (Configuration)

The concept of Configuration is familiar to every technical person. It can be said that a system that does not provide several Configuration parameters is embarrassed to go online and say hello to other systems. So why would be like this, in its essence is that we humans can’t control and predict everything, mapping to the software, we always need some features of system set aside some control thread, so that we need in the future, can be artificially stir the thread to control the behavior characteristics of the system, I call it “Dynamic attitude adjustment during System Runtime”.

To take a simple example,

logLevel = INFO

In a production environment, only WARNING/ERROR logs are generated. If the system is faulty, the output of logs is dynamically adjusted to DEBUG or TRACE, which contains diagnostic information.

Software’s old friend – configuration files

In the stand-alone system era, we used configuration files to store configuration items. A configuration item, such as logLevel above, contains the = expression, as follows:

config_key = config_value          // value1 or value2, you can choose one from the config_value set
Copy the code

In general config_Value should be a finite set of values and should be optional. If config_Value is not optional, THEN I can only assume that this configuration item must be fucking kidding me. A configuration file is generally a set of configuration items or a configuration set. A system can have one to multiple configuration files based on logical modules. The diagram below:

In the era of centralized development, basic enough to use the configuration files, because at that time the configuration management usually will not become a big problem, a little bit more simple, the system on the production, if need to modify a configuration, login to the production machine, vi to modify this configuration file, and then reload it isn’t a great burden.

The diagram below:

So there was no standard for configuration management in J2EE, the standard for enterprise application architecture. Of course, some manufacturers following J2EE standards, such as WebLogic, the middleware of Oracle, have done some work in this area in practice because the environment of many large enterprise customers is also quite complicated. WebLogic supports a feature called Deployment Plan, as shown in the following figure:

The essence behind it is that the configuration files in the application WAR package produced by developer (DEV) are some PlaceHolder, and the depoloy Plan XML file matching the target environment will be provided when the deployer (OPS) deploys the WAR package. The WebLogic Server itself replaces the PLACEHOLDER value of the WAR package configuration item with the value in the plan at the Deploy stage.

Distributed systems pose challenges to system configuration management

As for what is distributed system, this article will not repeat, there is no doubt that today ali’s system is one of the large, service-oriented, complex, distributed system implementation. There are three books worth reading in this area: Distributed System Concepts and Design, Distributed System Principles and Generics, and Distributed Systems For System Architects, Interestingly, only the last book Of the three books briefly mentioned Configuration Of Distributed Systems in section 21.3, which simply explained the concept and difference between static Configuration and dynamic Configuration “… System configuration may be static or dynamic…” .What does this show? This shows ali technology of us including our middleware today many of the problems faced and field has entered the deep, no one will give you this field directly clear solution, we are standing in the front, and our success or failure of the exploration, the experiences and achievements should summarize and share with the entire industry.

Over the past 15 years or so, software engineering in how to adapt to the continuous evolution of software has to be demand has many breakthroughs in methodology, and a lot of practice in this field, from an object-oriented design methodology, to the extreme programming (xp), to the agile development, continuous integration, unit test, etc., the theory and practice are more mature, The key is that the suite of tools and software that goes with this methodology has become very mature.

A very interesting thing here is about system Evolution or Software Evolution. A system or Software will go through research and development, testing, and finally go live, which is put into production system after it is created. So after that, how do you continuously and painlessly add new behaviors or adjust the characteristics of existing behaviors? It’s really complicated, especially when it comes to painless systems, where tuning means something can go wrong. Dynamic configuration management of systems is undoubtedly a small part of this, and if every tweak to the system’s behavior requires the entire system to be shut down, restarted, or even rebuilt, released and deployed to achieve this goal, it may be more difficult to achieve painless.

In a distributed system, a build, release, online is very, very heavy of a process, it is not like a single time to restart a machine, a process, in a distributed system, it involves the package (e.g., war) distribution to be more than thousands of machines, and then will restart thousands of machine application process of such a process, How long does it take for an application with more than 2000 machines to complete the release process, I believe many of the core systems of the small two are deeply aware of.

Therefore, how to adjust the behavior characteristics of the whole cluster (i.e., the flight attitude of the system) is a problem that must be answered by a distributed system under the condition of continuous application of the cluster. From this perspective, we believe that:

It is now easy to understand the common configuration changes to distributed systems such as:

  • Thread pool, connection pool size
  • Switch, plan, and traffic limiting configuration
  • toggleFeature
  • Data source ACTIVE-passive Dr Switchover
  • Routing rules
  • I was blah, blah, blah

The essence behind all this is to adjust the behavior characteristics (flight attitude) of the distributed system while it is running.

Every distributed system should have a dynamic configuration management system

Yes, you must have noticed that the statement here is a little different from the picture. What I want to emphasize here is that not all configuration centers are necessary. In a distributed system with a small scale, for example, one company has two application clusters, so whether you use configuration file +auto-reload, redis, ZooKeeper, whatever can be used. This dynamic configuration management system does not have to be a stand-alone system and can be independent of other systems, such as registries, or even a subsystem of messaging middleware. But it is important to know that there must be something that gives your system the ability to dynamically adjust its behavior, and that the basic inherent features of a CONFIGURATION management system must be implemented.

The difference between dynamic and static configuration

There was a time when I didn’t know the difference, and that’s normal. Dynamic and static this is a relative concept, the seas run dry and the rocks rot forever that is not called configuration, may be flirty nonsense, even though the configuration may be placed in a text that looks a lot like a configuration file, configuration must be possible to change its value, Dynamic configuration depends on whether the configuration is strongly bound to the build-deploy lifetime of the application. If a configuration item is uncoupled from the build of the software, the only thing that might need to change is a dynamic configuration when the application is running, even if the frequency of change is very low. Maybe you design a configuration item and you don’t change it once in the last three years. That’s a dynamic configuration. Configuration changes only happen at the point when the software version is built and released, so that’s static configuration. Even if you build frequently, coming every hour, that’s static configuration. For a simple example:

The build - version = 3.4.6-1569965Copy the code

This configuration item will always change its value only when a version of software is built. Once the version is built and the program runs, there is no need for change. This is a static configuration bound to the build. The logLevel example given at the beginning of this article is an example of dynamic configuration.

So if you look at the configuration items on your system, you’ll see that dynamic configuration is actually more, and almost everything that’s related to behavior evolution is dynamic configuration.

Why Taobao

After I joined Ali to do Diamond, I thought about an interesting thing: why did the independent configuration center first appear on Taobao? If you search “configuration center” on Baidu, a famous search engine for bidding ranking in China, you will find that there is not much information, but the information in the front is XDiamond, a family of Diamond like SuperDiamond. Anyway, we have not paid any money to Baidu for associating configuration center with the name Diamond. So this search result should be a natural result, the side also reflected in the domestic speaking configuration center in the production of large-scale use is the only one, there is no semicolon.

In the industry, as shown below, Spring Boot/Cloud microservices are still in the preaching stage of introducing a registry (Discovery Service) and a configuration Service (Configuration Service).

And given the technical limitations of the way Spring is implemented, it seems that no company’s solution based on this configuration center has actually supported large-scale distributed systems in production. After all, looking through all the blogs and articles, no foreigner has even started to mention that, How this Git-based solution should address multiple data centers and non-functional requirements related to disaster recovery.

Back to the question, why taobao? We all know that Taobao took the lead in the domestic industry in initiating IOE removal and fully adopting MYSQL. In this process, ali and Ali middleware undoubtedly solved the problem of database and table division on a large scale and systematically in China. One of the core issues associated with TDDL is where the configuration information of the data source of multiple libraries is stored after the database is divided into tables, and the application is shielded from the fact of multiple libraries. Well, maybe you know the rest, put it in the configuration center! However, it should be mentioned that Diamond was not in the registry (ConfigServer), and then Diamond was separated from ConfigServer. In this process, many people saw the difference between persistent and non-persistent data and the stability of the product at that time. This is still true today, but over the years of practice and evolution, it has become clear that Service Discovery and Dynamic Configuration Management are fundamentally different things. It may have been a hunch at the time.

Mo Daojun early, more early pedestrian

Sometimes we feel a little “superiority” and “vanity” because we are early in a certain field. We used to think that Dynamic Configuration For Distributed System was not the first in the industry, but definitely in the forefront. But the following two elder brothers remind us once again, the technical people steady forward, do not have unnecessary ideas:

In April 1985, the two brothers, IEEE TRANSACTIONS ON SOFTWARE ENGINEERING published a Paper called Dynamic Configuration for Distributed Systems, 1985!! What do you mean? I was four years old, playing in mud, wearing open-crotch pants. None of Diamond’s major technical architecture developers were even born yet!! All we can do is pay our respects to these two predecessors again!

In this paper, although from today’s point of view, people’s understanding of distributed system at that time is very different from that of today, but the problems identified in it are very accurate:

“… .Dynamic systemc onfiguration is the ability to modify and extend a system while it is running. The facility is a requirement in large distributed systems where it may not be possible or economic to stop the entire system to allow modification to part of its hardware or software. It is also useful during production of the system to aid incremental integration of component parts, and during operation to aid system evolution.The paper introduces a model of the configuration process which permits dynamic incremental modification and extension. Using this model we determine the properties required by languages and Their execution environments to support dynamic configuration…”

And it clearly distinguishes the basic model of static configuration from dynamic configuration:

Configuration and Environment

Another technical concern is the “Context” property of “configuration”. This expression can be a bit abstract and difficult to understand. It’s a bit like the technical term Context, where many components associate a Context, Component+Context is a complete runtime story. Environment is also one of the questions that people might ask in the post. Why does Diamond expose so many environments for the app to choose from? Those who are more familiar with middleware may ask, in a unified scenario, why is the registry a large cluster pattern and the configuration center a small cluster pattern? On the other hand, multiple environments are also one of the factors aggravating the need for distributed systems to rely on an independent configuration management system. It can be said that the more complex the environment of the company, the more distributed applications and services, the more likely the company will have an independent configuration center system.

A few easy-to-understand statements to help you understand the environment properties of the configuration,

“Set logLevel to DEBUG in the development environment, INFO in the pre-release environment, and WARNING in the production environment.”

“The maximum number of threads in the execution thread pool should be set to 15 in everyday environments, and a larger value should be set to 150 by default in production environments.”

“In the online environment, the application data source in the central machine room should be connected to library A, while the application in the S machine room should be connected to library B nearby.”

“Bidirectional synchronization switch should be turned off only in T environment”

“This is a bit of a big change, the new feature will only be available in unit H online, the rest of the unit environment is not available yet.”

Yes, I believe you must have found that the specific value definition of one of our configuration items is often associated with the specific environment. In reality, a considerable part of the configuration must be set to different values in different environments, but a considerable part of the configuration must be set to completely the same value in different environments. So from an application’s point of view, of the 100 configuration items, 50 May have different values for each environment, and 50 May have exactly the same values for all environments. This alienation brought complexity to the design of the configuration management system, and the final semantic interpretation, clearly should not be in the center of the configuration of the system itself, should be given to applications, configuration management system should do is to provide a convenient way of interaction to ensure the consistency of the two different demands well meet at the same time, this kind of appeal is divided into three aspects, the following diagram:

Yes, I believe you must have found that the specific value definition of one of our configuration items is often associated with the specific environment. In reality, a considerable part of the configuration must be set to different values in different environments, but a considerable part of the configuration must be set to completely the same value in different environments. So from an application’s point of view, of the 100 configuration items, 50 May have different values for each environment, and 50 May have exactly the same values for all environments. This alienation brought complexity to the design of the configuration management system, and the final semantic interpretation, clearly should not be in the center of the configuration of the system itself, should be given to applications, configuration management system should do is to provide a convenient way of interaction to ensure the consistency of the two different demands well meet at the same time, this kind of appeal is divided into three aspects, the following diagram:

Diamond provides all three of these capabilities, and 1,2 are typically represented in client libraries and OPS provided by the configuration center. 3 this implementation is more difficult, because in general, between multiple environments are some physical constraints, such as long-distance network or network isolation, to do distributed uniformity and considerations, such as partition tolerate sexual Diamond, currently only support online multi-cell consistency constraint rules, but because people don’t have to use real historical reasons, The rules themselves are not abstract enough or generic enough. Now we are doing renovation, the future will do more general consistency rules, behind will guide you to use, so much for those environment to maintain consistent the configuration items, environmental complexity can block out of the application, if an application configuration items are all consistent to the environment, so it will be good for you, the sky wave to five words, “so many” environment is not a thing.

In addition, A configuration center also should have the ability is to configure the set of export, import function, can make convenient application environment the configuration in A set of export and import to the environmental capacity of B, it has great significance on three scene, A scene is online configuration values is proven by practice, now in daily or pretest new application environment, Hope to online configuration copy to offline use up, the second is that offline application finally transferred to pretest or online, the better configuration want to line up at a draught, this according to our experience, of course, must be careful, the third is a new station or room, application will need in the new room all configuration migration in the past, Diamond will soon open up this ability.

With this in mind, you’ll have a better idea of what’s going on with the Abstract Environment and PropertySource in the Spring Framework. See:

Spring 3.1 M1: Unified Property Management

Spring. IO/blog / 2011/0…

Three configured properties

  • Environmental properties
  • Sparse change attribute
  • Rapid spread

Environmental attributes have been discussed above.

Sparse change means that configuration changes are basically sparse, because the behavior of the system cannot be dynamically adjusted very frequently. If you adjust the behavior of the system every 100 milliseconds, the system will probably be angry with you.

While fast propagation is about configuration unchanged, a change often requires all nodes of the target cluster to almost receive the change at the same time, and then almost uniform uniform adjustment behavior. In the scenario of database cutting, after the active/standby switchover, the application cluster writes a new master database. This behavior switch is sparse and the whole convergence takes a day. The application cannot stand it.

The difference between configuration center (Diamond) and registry (ConfigServer)

In our eyes, with local dialect, this is the difference between the tortoise and the bastard, want to use a bit of gold, this is the difference between gold bars and diamonds, said the western style this is called Apple and Pear, but the name of the original brought us big trouble, Our service registry is now called Config Server. However, many middleware products bear the name of a period of 8 years of history, this name also reflects the middleware to continue to do technical products, persistence is a power of belief in it, N generations of continuous development of a product, to tell the truth, just live regardless of the phenomenon in middleware can not say no, but it is really very few. An eight-year-old product is like an eight-year-old child, who has gone to primary school, and wants to change its name from Zhu Shishan to Zhu Baoshan. His classmates have to make a very big question mark about whether to recognize it, and they have to go to the police station to re-register their hukou, which is also a trouble.

So the name of the product has a university asked and big terror, we must find a fortune teller to calculate before the name, originally I became a code before that is also immortal, river’s lake to send nickname Guo Banxian, then you can nail hair a red envelope for me to calculate. But after becoming a code farmer, I don’t say anything, it’s all tears, I lost a lot of skill points I got before, and now I look at computers and codes most pleasing to my eyes.

For details, see << What is the difference between an application configuration center and a service registry? >>

About configuration, latest developments in the industry

There are few famous professional configuration center products in the industry (Diamond Ao Qiao ing~), and most of them are based on git, Redis, Zookeeper, Consul, etc., so if you want to know about the configuration center, you can directly learn about Diamond. : -)

However, there are some libraries that are very popular for configuration management client programming libraries. If you are interested, you can check them out:

If you read it carefully, and if you know Diamond, this is what Diamond has been working on for years, Spring has finally moved from a lot of configuration files to externalized configuration in a distributed system, and this time we are ahead of the game.

Look at the owner’s announcement,

Java fucking properties Reinvented! The reinvention of Java Properties! Dream is not dream? ! Monk monk I think, we are poor farmers sometimes Chinese yards that the ability of refining and sublimation, just when feel to maintain and modify the previous bad code is a very helpless really painful, very Low, but Martin Fowler called it a “reconstruction”, and then write a book, and then after we read, incredibly still feel his mama of, Speak of really very reasonable! After changing rotten code to refactoring, I suddenly realized that this was a really cool thing to do!

Configuration and Metadata

Many people don’t make this distinction, but there are subtle differences between configuration centers.

Configuration as described above, configuration modification is basically driven by people, and changes are realized in OPS.

The essence of metadata is a small piece of program metadata, which is mostly generated and consumed by the program and changed by the program through calling Diamond’s client API, without OPS or human intervention.

What’s the point of knowing that? There is no doubt that the configuration of such a requirement selection is relatively clear, and metadata, such as metadata, can choose too many Pub-sub systems, such as message queue products, distributed coordinator products such as ZooKeeper, k-V store with pub-sub capabilities such as Redis, and so on. So if it’s metadata, what to choose needs to be careful, which is useful, save, to fully assess and grasp their own needs.

Diamond is not only an application configuration store, but a large part of the data it stores is metadata, so Diamond is actually a metadata storage center.

conclusion

Such a long article, you can persist in reading here, it shows that you are the real, out of the vulgar interest, pure code farmers, ape elite! Configuration center, it does not have sophisticated technology, difficult algorithm, massive data, do this thing only need a spirit is enough.

Owner has been doing configuration file support for a long time, but now owner has also started to transition to integration with ZooKeeper and other configuration centric solutions, so it is not a lie to say that the industry is moving towards configuration centric solutions.

Enterprise Internet architecture Aliware lets you cloud your business capabilities: www.aliyun.com/aliware