Software Architecture
ZSphere software architecture highlights:
- Fully Asynchronous Architecture: Asynchronous messaging, methods, and HTTP calls.
- Asynchronous messaging: Services communicate via a message bus. When calling a service, the source service sends a message to the destination service, registers a callback function, and returns immediately. Upon task completion, the destination service triggers the callback with results. Asynchronous messages can be processed in parallel.
- Asynchronous methods: Services communicate through asynchronous messages. Components or plugins inside each service use asynchronous method calls, following the same pattern as asynchronous messaging.
- Asynchronous HTTP calls: Each plugin has an agent that puts a callback URL in the HTTP header of every request. After task completion, the agent sends the response to the caller's URL.
- Based on these three asynchronous approaches, ZSphere builds a layered architecture to ensure all components operate asynchronously.
- With this fully asynchronous architecture, a single management node can process tens of thousands of concurrent API requests per second, while managing tens of thousands of hosts and hundreds of thousands of virtual machines.
- Stateless Services: Each request is independent.
- Compute node agents, storage agents, network services, console proxy services, and configuration services have no dependencies between requests. Each request carries all required context, so nodes do not need to retain request state.
- Resources such as management nodes and compute nodes are identified by UUIDs and assigned through a consistent-hashing ring. Message senders do not need to know which service instance handles a resource, and service instances process messages without exchanging resource state.
- Little information is shared among management nodes. Therefore, a minimum of two management nodes can meet the requirements of high availability and scalability.
- Stateless services improve resilience because restarting a server does not lose request state. They also simplify scaling management services out or in.
- Lock-Free Architecture: Consistent hashing algorithm.
- The consistent hashing algorithm ensures all messages of the same resource are always processed by the same service instance. This message aggregation to specific nodes reduces synchronization and parallel processing complexity.
- Work queues replace lock contention. Operations that must be serialized for the same resource are queued in memory, while operations on different resources can run in parallel.
- This queue-based, lock-free architecture increases task concurrency and system performance.
- In-Process Microservices: Decoupled microservices.
- A message bus isolates and controls services, such as virtual machine services, identity authentication services, snapshot services, volume services, network services, and storage services. All microservices are enclosed in the management node process. These services communicate with each other through the message bus. All messages are first sent to the message bus, then forwarded to the destination service using consistent hashing ring.
- In-process microservices use a star topology in which each service runs independently. This design decouples centralized control functions and isolates services so that a service failure does not directly affect other components.
- Versatile Plugin System: Horizontally scalable plugins.
- Every plugin provides services independently. Any newly added plugin has no impact on other existing plugins.
- Plugins support the Strategy and Observer patterns. Strategy plugins implement parent-class interfaces for specific functions. Observer plugins register listeners for internal events and trigger the corresponding workflow when an event occurs.
- This horizontally extensible plugin system allows ZSphere to add and update capabilities without weakening the core architecture.
- Workflow Engine: Sequence-based management and error rollback.
- Each workflow is defined in XML. If an error occurs, the workflow rolls back the completed steps in reverse order and cleans up temporary resources.
- A workflow can contain subworkflows that implement additional business logic.
- Tag System: Enables business logic change and resource attributes.
- Extend or modify business logic dynamically through system tags and plugins.
- Group and categorize resources with tags, enabling resource searches by specific tags.
- Cascade Framework: Supports chained resource operations.
- The Cascade framework manages dependencies through chained resource operations. For example, detaching or deleting a resource triggers the corresponding operations on related resources.
- Resources can be added to the Cascade framework as plugins. Their addition or removal does not affect other resources.
- The cascading mechanism enables flexible and lightweight resource configuration, allowing rapid adaptation to customer configuration changes.
- Automated Deployment: Agentless auto-deployment with Ansible.
- Agentless Ansible automates dependency installation, physical resource configuration, and agent deployment. The process requires no additional user intervention, and reconnecting an agent can trigger its upgrade.
- Comprehensive Query APIs: Access any attribute of any resource.
- Provides comprehensive query APIs that support large numbers of conditions and flexible condition combinations.
