Introduction: Reflecting on Blogging
My journey with Apollo primarily relied on three processes: training videos, official documentation, and sample code. Along the way, I gradually realized that learning predominantly through training videos and blog posts leads to a fast-food-style consumption of knowledge, which isn’t conducive to deep learning.
While this approach allows for the rapid acquisition of knowledge, learners often fail to achieve a true mastery of the content. Documentation learning varies in difficulty depending on the developer’s writing skills and the reader’s familiarity with the subject matter. However, this method can afford readers more time for reflection, making it a valuable learning approach.
Additionally, this blog post on the Apollo Configuration Center was completed during my spare time, so most of the content is derived from official documentation. The main purpose of documenting this blog is to deepen my understanding and impression of microservices architecture. As for the specific implementation details, they should be referred to the official documentation.
Configuration
Applications often need to read configuration information during startup and runtime, with configurations accompanying the application throughout its lifecycle. This includes parameters like database connection strings and startup parameters.
Configurations have several characteristics:
- Independent Read-only Variables:
- Configurations are independent of the program; the same program behaves differently under different configurations.
- Furthermore, configurations are read-only for the program; the program adjusts its behavior based on configuration but should not modify the configuration itself.
- Accompanies Application Lifecycle:
- Configurations span the entire lifecycle of an application, used for initialization during startup and behavior adjustment during runtime. For example, reading service port numbers during startup or executing scheduled tasks based on timing policies during runtime.
- Multiple Loading Methods:
- Common loading methods include hardcoding within the program, configuration files, environment variables, startup parameters, and database-based configurations.
- Requires Governance:
- Permissions Control: Since configurations can alter program behavior, incorrect configurations could lead to disasters. Therefore, configuration modifications must have robust permission controls.
- Environment and Cluster Configuration Management: The same program often requires different configurations in different environments (development, testing, production) or clusters (different data centers). Hence, comprehensive environment and cluster configuration management is essential.
Configuration Center
Traditional monolithic applications have inherent flaws, including decreased deployment efficiency with scale, poor team collaboration efficiency, decreased system reliability, maintenance difficulties, and lengthy new feature deployment cycles. Thus, there’s an urgent need for a new architecture to address these issues, and microservices architecture is one of the solutions.
When a system transitions from a monolithic application to a distributed system with individual service nodes, configuration files must also migrate (split). This disperses configurations, often leading to redundancy.
The configuration center abstracts configurations from applications for centralized management. This resolves issues related to dynamic configuration changes, persistence, and operational costs.
Applications no longer need to add configuration management interfaces or implement configuration persistence themselves, nor do they need to introduce “scheduled tasks” to reduce operational costs.
In summary, the configuration center is a fundamental service component for centrally managing various application configurations.
In the system architecture, the configuration center is a component of the entire microservices infrastructure. A qualified configuration center should:
- Allow easy reading and modification of configuration items.
- Simplify the addition of new configurations.
- Support monitoring of configuration changes to control risks.
- Provide a history of configuration modifications.
- Support isolation across different deployment environments.