Skip to content

Deployment

João edited this page Mar 5, 2021 · 3 revisions

Contents

  1. Local Cluster Configuration
    1. Manual Deployment

Cluster Configuration

A configuration for local testing, can be obtained by the model in the figure below, where there is a cluster of 4 servers in a complete graph topology.

(Click for larger view)

Some properties are proposed for the algorithm, such that the timeout for an election varies between 2 and 3 seconds and a heartbeat happens every second. Since the cluster contains only 4 servers, the Quorum is 3, meaning that this configuration tolerates the failure of one of the servers because it needs 3 of them (the majority) to reach consensus.

Manual Deployment

To test locally, you can use a text editor that can edit executable configurations, such as IntelliJ.

Another simple way to test this configuration is to open 4 different terminals and put a different command in each one. For this specific case, you need to be in the servlet/ folder and the commands to be executed are:

  • Terminal 1:
mvn spring-boot:run -Dspring-boot.run.arguments="--server.address=localhost --server.port=8001 --raft.hostname=localhost:8001 --raft.cluster=localhost:8002,localhost:8003,localhost:8004 --raft.election-timeout-min=2000 --raft.election-timeout-max=3000 --raft.heartbeat=1000"
  • Terminal 2:
mvn spring-boot:run -Dspring-boot.run.arguments="--server.address=localhost --server.port=8002 --raft.hostname=localhost:8002 --raft.cluster=localhost:8001,localhost:8003,localhost:8004 --raft.election-timeout-min=2000 --raft.election-timeout-max=3000 --raft.heartbeat=1000"
  • Terminal 3:
mvn spring-boot:run -Dspring-boot.run.arguments="--server.address=localhost --server.port=8003 --raft.hostname=localhost:8003 --raft.cluster=localhost:8001,localhost:8002,localhost:8004 --raft.election-timeout-min=2000 --raft.election-timeout-max=3000 --raft.heartbeat=1000"
  • Terminal 4:
mvn spring-boot:run -Dspring-boot.run.arguments="--server.address=localhost --server.port=8004 --raft.hostname=localhost:8004 --raft.cluster=localhost:8002,localhost:8003,localhost:8001 --raft.election-timeout-min=2000 --raft.election-timeout-max=3000 --raft.heartbeat=1000"

After this the servers start their execution, you can see the leader election happening. You can also kill a server and put it back online (or not), to see the algorithm dealing with the failure of that server.

Clone this wiki locally