开发者

What is the difference between system configuration and system state?

开发者 https://www.devze.com 2023-01-16 17:02 出处:网络
Today in a design meeting we discussed the topic of where to store configuration and state of a distributed application.

Today in a design meeting we discussed the topic of where to store configuration and state of a distributed application.

It turns out that in that meeting, some developers understand different things when they hear configuration or state. Some even think that configuration and state are exactly the same thing.

My very shortly summarized understanding is that configuration describes how you want the system to behave, and the system should parse that config and take actions to reach a certain state that reflects an implementation and consolidation of that config.

For example, an Apache server may have a config that tells it to have between 15 and 30 worker processes. When the server starts, it will most likely start 15 of them, arriving to a state of having 15 worker processes. As requests come in it might change its state to have up to 30 active worker processes.

I couldn't however开发者_运维问答 convince the developers in question that these two concepts are different, and googling doesn't give me more eloquent references that explain better than I can what the me almost obvious difference is.

Any suggestions or links on how to explain this better ? Or am I wrong ?


You can reset a system, losing all state. Its configuration remains.


"Configuration" could be taken to include the intended lifelong state of the app -- the state that's there whether there's anything to do or not; the internal values that say how the non-hardcoded stuff happens. It's normally obtained from some external source like a configuration file, but the config is not actually the file itself, or even the contents of that file -- it's the app's behavior once the contents of that file have been parsed and applied.


As per Merriam-Webster (emphasis mine):

state noun, often attributive

1 a : mode or condition of being (a state of readiness)

con·fig·u·ra·tion noun

1 a : relative arrangement of parts or elements: as (1) : shape (2) : contour of land (3) : functional arrangement (a small business computer system in its simplest configuration)

b : something (as a figure, contour, pattern, or apparatus) that results from a particular arrangement of parts or components

I can see how you would associate the (b) meaning of configuration with state, but that's not the definition I usually think of when discussing a system's configuration. State describes behavior / properties at a specific moment in time, whereas I take configuration to mean the state in which a system is meant to or initialized to behave.


From a theoretical perspective, there is no difference between configuration and other data that is provided to a program from the outside. Both are classified as Input. I think that any attempt to define "configuration" as something special is going to be met with endless edge cases and exceptions, so that is not a natural category.

On the other hand, there is a clear difference between Input and State. Input is provided from the outside, while State is internal.

With this in mind, consider that some applications are designed to be stopped and restarted at any time to perform a very long running process. For those appliations the distinction between Input and State are minimized, since total program state must be serialized to persistant media in order to allow the program to continue where it left off in the future. This is especially common among distributed applications.

It is possible that for the particular application that you are working on, there really is no distinction between configuration and state.


If we are talking about systems, then the state of a system is precisely the values of all of the variables of the system at some point in time, The state is expected to change as the system performs it functions; that is how a system does its business.

Configuration, on the other hand is the list (or better, set) of state variables that the system has and that can change value or a state.

So, a configuration variable might be temperature, while the corresponding state of that temperature variable is 30 degrees.

Now, this becomes a little complicated for systems because a system is a set (or at least a group) of components that operate together to achieve a function or a mission. We want the value of each component configuration variable to be in a good state (that is, to have proper values for its variables).


I just had the same conversation a day or two ago and ended up on this post because of it. I think the best thing I could come up with to distinguish the two is that:

state is something set by the system as an input to itself.

configuration is something set by the user as an input to the system.

Note that these are not definitions for the two terms, but rather the thing that distinguishes them. Both terms imply that they could change and produce different behaviors in the system. I'd consider things like temporary files, programmatically-written database entries, and memory shared between processes to be state by this distinction, and command flags, config files, and constants to be "configuration".

I think this conforms with @djna's observation that resetting a system wipes away state, but not configuration.

Anyways, sorry for digging up an 8 year old topic!

0

精彩评论

暂无评论...
验证码 换一张
取 消