- The DevOps 2.1 Toolkit:Docker Swarm
- Viktor Farcic
- 325字
- 2021-07-09 21:03:38
Scaling services
We should always run at least two instances of any given service. That way they can share the load and, if one of them fails, there will be no downtime. We'll explore Swarm's failover capability soon and leave load balancing for the next chapter.
We can, for example, tell Swarm that we want to run five replicas of then go-demo service:
docker service scale go-demo=5
With the service scale command, we scheduled five replicas. Swarm will make sure that five instances of go-demo are running somewhere inside the cluster.
We can confirm that, indeed, five replicas are running through the, already familiar, service ls command:
docker service ls
The output is as follows (IDs are removed for brevity):
NAME MODE REPLICAS IMAGE
go-demo replicated 5/5 vfarcic/go-demo:1.0
go-demo-db replicated 1/1 mongo:3.2.10
As we can see, five out of five REPLICAS of the go-demo service are running.
The service ps command provides more detailed information about a single service:
docker service ps go-demo
The output is as follows (IDs and ERROR PORTs columns are removed for brevity):
NAME IMAGE NODE DESIRED STATE CURRENT STATE
go-demo.1 vfarcic/go-demo:1.0 node-3 Running Running 1 minute ago
go-demo.2 vfarcic/go-demo:1.0 node-2 Running Running 51 seconds ago
go-demo.3 vfarcic/go-demo:1.0 node-2 Running Running 51 seconds ago
go-demo.4 vfarcic/go-demo:1.0 node-1 Running Running 53 seconds ago
go-demo.5 vfarcic/go-demo:1.0 node-3 Running Running 1 minute ago
We can see that the go-demo service is running five instances distributed across the three nodes. Since they all belong to the same go-demo SDN, they can communicate with each other no matter where they run inside the cluster. At the same time, none of them is accessible from outside:

What happens if one of the containers is stopped or if the entire node fails? After all, processes and nodes do fail sooner or later. Nothing is perfect, and we need to be prepared for such situations.
- 精通MATLAB圖像處理
- Dreamweaver 8中文版商業(yè)案例精粹
- 并行數(shù)據(jù)挖掘及性能優(yōu)化:關(guān)聯(lián)規(guī)則與數(shù)據(jù)相關(guān)性分析
- 機器學(xué)習(xí)與大數(shù)據(jù)技術(shù)
- Blender Compositing and Post Processing
- 項目管理成功利器Project 2007全程解析
- 人工智能趣味入門:光環(huán)板程序設(shè)計
- 網(wǎng)站前臺設(shè)計綜合實訓(xùn)
- 基于Xilinx ISE的FPAG/CPLD設(shè)計與應(yīng)用
- Excel 2007常見技法與行業(yè)應(yīng)用實例精講
- 悟透AutoCAD 2009案例自學(xué)手冊
- 手機游戲程序開發(fā)
- ESP8266 Robotics Projects
- Cortex-M3嵌入式處理器原理與應(yīng)用
- 筆記本電腦使用與維護