High availability and performance and modifiability are very important for distributed systems. If we can provide auto-scalable features, it will improve software quality and simplify the maintenance of the system.
How to make distributed systems to be auto-scalable?
There are 2 places to make the system auto-scalable: one is the nodes itself, the other is the entry point to access these nodes.
I will introduce the following two scenes, all the nodes (service nodes and the entry point to access these nodes) we can control, and some nodes (the entry point to access these nodes) we can't.
In this scene, the entry point node provider the target service node for client, and the entry point node we can fully control and realize it.
The system has 4 roles: Clients/Entry Point/Service Node/Register Server.
The service nodes provide business service.
The Register Server provides register service. Both the entry point nodes and service nodes register theirs information in the register server when they start and unregister when they exit. The Service Nodes provide the heartbeat info and write it to the register server.
The Entry point nodes can monitor the service nodes according to the register server and get the information about the service nodes from the register server. So the entry point node can know the service nodes changes and status and provide suitable service node for Clients when the Clients arrive.
In this Scene, the entry point nodes keep HA and do not change. Clients just access the entry point node to get suitable service node information and the service nodes provide service to the client.
When the service nodes are added to system, the entry point nodes knows it transparently and provide the new node to the clients when new clients arrive.
When the service node is removed from the system, the entry point nodes also knows the change of the service node, and remove information about the removed service nodes .Nothing else should be changed, and the system gets the auto-scalable feature.
In this Scene, there are 5 roles: Clients/EntryPointNodes/ServiceGateWayNodes/ServieNodes/RegisteServerNods.
The Register Server nodes and clients and service nodes are the same as Scene 1.
The service gateway nodes and service nodes both register to the register server, and write heartbeat information to the register server. But the service gateway nodes monitor the service nodes status by the register server node, so when the service nodes change, the service gateway nodes can know all the change of the service nodes.
The entry point node is a mature product, so we can't get full control of it, but we can add a plugin module to it. The plugin module is responsible for modify the route information dynamically by monitoring the change of the service gateway nodes.
When the service nodes or the service gateway nodes change, the system can know the change of them, and remove the nodes from system or add the nodes to system transparently.
According the Scene introduced above, we can know the system is designed by registering node and monitoring them that it can easily process the change of nodes and achieve auto-scalable feature.
At the last, if we want to add or remove the nodes automatically according the load of the system in future, we can use PaaS(IaaS) to deploy and manage the nodes which should be deploy dynamically.