Skip to content

A Quick Way to Run TPS

Deng Lun edited this page Nov 21, 2019 · 8 revisions

A Quick Way to Run TPS

This is a tutorial to help you run GoQuarkChain clusters and get your own TPS record real quickly.

Here is a demo video for the same purpose.

Demo

For more detailed information please refer to this doc.

##System Requirements

First of all, you need to get a bunch of machines prepared to run clusters. It is required that they have:

  • Ubuntu 18.04,
  • SSH server installed and running,
  • root account is enabled,
  • Docker version >= 18.09.7, and
  • 38291, 38391, 38491, [48000, 48000 + host number] ports opened.

Better to have, they are all in the same subnet.

##Run Docker Image

In one of your hosts, or your laptop of any OS with Docker installed, run the following commands to pull the Docker image and start a container:

# specify a version tag if needed; use 'latest' for latest code
sudo docker pull quarkchaindocker/goquarkchain:<version tag>
sudo docker run -it --name deployer quarkchaindocker/goquarkchain:<version tag> /bin/bash

Then you will be inside a Docker container named deployer.

##Configure Clusters

With the file deployConfig.json, you can configure multiple clusters connected to each other.

# inside Docker container 'deployer'
cd $GOPATH/src/github.com/QuarkChain/goquarkchain/tests/loadtest/deployer
vi deployConfig.json

Or,you can update the file outside, and copy it into Docker:

# outside Docker container 'deployer'
sudo docker cp deployConfig.json deployer:/go/src/github.com/QuarkChain/goquarkchain/tests/loadtest/deployer

Here is a simple example in which 3 clusters are deployed on 3 hosts:

{
  "DockerName": "quarkchaindocker/goquarkchain",
  "Hosts": [
	{
  	"IP": "192.168.183.158",
  	"Port": 22,
  	"User": "root",
  	"Password": "password",
    	  "IsMaster": true,
    	  "SlaveNumber": 1,
  	  "ClusterID": 0
	},
	{
  	"IP": "192.168.183.159",
  	"Port": 22,
  	"User": "root",
  	"Password": "password",
    	  "IsMaster": true,
    	  "SlaveNumber": 1,
  	  "ClusterID": 1
	},
	{
  	"IP": "192.168.183.160",
  	"Port": 22,
  	"User": "root",
  	"Password": "password",
    	  "IsMaster": true,
    	  "SlaveNumber": 1,
  	"ClusterID": 2
	}
  ],
  "CHAIN_SIZE": 2,
  "SHARD_SIZE": 4,
  "ExtraClusterConfig": {
	"TargetRootBlockTime": 20,
             "TargetMinorBlockTime": 4,
	"GasLimit": 96000000
  }
}

NOTE TPS competition requires that:

  • The number of clusters: >= 3
  • TargetRootBlockTime: 20s ~ 60s
  • TargetMinorBlockTime : 4s ~ 10s
  • GasLimit:<=96,000,000

For detailed explanation of the configurations and more advanced example please refer to here.

##Deploy and Run Clusters

The following command will deploy Docker containers named bjqkc with cluster executables to remote hosts, and start the services of each cluster one by one:

# inside Docker container 'deployer'
go run deploy_cluster.go

If everything goes correctly, you will see from deployer console log that each cluster started successfully and peers connected to each other.

##Start Mining

NOTE the following steps will be executed inside one of the deployed Docker containers (all named bjqkc). Log in to one of the hosts running master service of a cluster, and execute the following command to enter Docker container:

# outside Docker container 'bjqkc'
sudo docker exec -it bjqkc /bin/bash

Start mining:

# inside Docker container 'bjqkc'
curl -X POST -H 'content-type: application/json' --data '{"jsonrpc":"2.0","method":"setMining","params":[true],"id":0}' http://127.0.0.1:38491

##Generate Transactions

# inside Docker container 'bjqkc'
curl -X POST -H 'content-type: application/json' --data '{"jsonrpc": "2.0","method": "createTransactions","params": [{ "numTxPerShard": 10000,"xShardPercent": 0}],"id": 1}' http://127.0.0.1:38491

##Monitoring

Now you can observe the status of your clusters including TPS:

# inside Docker container 'bjqkc'
curl -X POST -H 'content-type: application/json' --data '{"jsonrpc": "2.0","method": "createTransactions","params": [{ "numTxPerShard": 10000,"xShardPercent": 0}],"id": 1}' http://127.0.0.1:38491

Enjoy!

Clone this wiki locally