Skip to content
Snippets Groups Projects
Unverified Commit 6b60d47d authored by Jonas Theis's avatar Jonas Theis Committed by GitHub
Browse files

Speed up Docker network through little caching trick (#423)

parent 6cbcef10
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
...@@ -162,8 +162,7 @@ class Datastructure { ...@@ -162,8 +162,7 @@ class Datastructure {
} }
getStatusText() { getStatusText() {
// avg = this.connections.size*2 / (this.nodesOnline-1) : -1 == entry node (always disconnected) return "nodes online: " + this.nodes.size + " - edges: " + this.connections.size + " - avg: " + (this.connections.size*2 / this.nodes.size).toFixed(2);
return "nodes online: " + this.nodes.size + " - edges: " + this.connections.size + " - avg: " + (this.connections.size*2 / (this.nodes.size-1)).toFixed(2);
} }
addNode(idA) { addNode(idA) {
......
...@@ -150,7 +150,7 @@ func monitorForDesynchronization() { ...@@ -150,7 +150,7 @@ func monitorForDesynchronization() {
timer.Reset(desyncedIfNoMessageInSec) timer.Reset(desyncedIfNoMessageInSec)
case <-timer.C: case <-timer.C:
log.Infof("no message received in %d seconds, marking node as desynced", desyncedIfNoMessageInSec) log.Infof("no message received in %d seconds, marking node as desynced", int(desyncedIfNoMessageInSec.Seconds()))
markDesynced() markDesynced()
return return
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
![Docker network](../../images/docker-network.png) ![Docker network](../../images/docker-network.png)
Running `docker-compose` spins up a GoShimmer network within Docker as schematically shown in the figure above. Running `./run.sh` spins up a GoShimmer network within Docker as schematically shown in the figure above.
`N` defines the number of `peer_replicas` and can be specified when running the network. `N` defines the number of `peer_replicas` and can be specified when running the network.
The peers can communicate freely within the Docker network The peers can communicate freely within the Docker network
while the autopeering network visualizer, `master_peer's` dashboard and web API are reachable from the host system on the respective ports. while the autopeering network visualizer, `master_peer's` dashboard and web API are reachable from the host system on the respective ports.
...@@ -23,14 +23,8 @@ Reachable from the host system ...@@ -23,14 +23,8 @@ Reachable from the host system
- `master_peer's` web API: http: http://localhost:8080 - `master_peer's` web API: http: http://localhost:8080
It is therefore possible to send messages to the local network via the `master_peer` and observe log messages either It is therefore possible to send messages to the local network via the `master_peer` and observe log messages either
via `docker logs --follow CONTAINER` or by starting the Docker network without the `-d` option, as follows. via `docker logs --follow CONTAINER` or all of them combined when running via:
``` ```
docker-compose up --scale peer_replica=5 ./run.sh 5
```
# remove containers and network \ No newline at end of file
docker-compose down
```
Sometimes when changing files Docker does not detect the changes on a rebuild.
Then the option `--build` needs to be used with `docker-compose`.
\ No newline at end of file
version: "3.5"
services:
builder:
container_name: builder
image: golang:1.14
working_dir: /tmp/goshimmer/
entrypoint: go install main.go
volumes:
- ../../..:/tmp/goshimmer:ro
- goshimmer-cache:/go
volumes:
goshimmer-cache:
name: goshimmer-cache
\ No newline at end of file
...@@ -15,8 +15,7 @@ ...@@ -15,8 +15,7 @@
"entryNodes": [ "entryNodes": [
"X2cmCzYnZDjmsvdAH90Q7oKmhNeTdwJdj2FX84adLzo=@entry_node:14626" "X2cmCzYnZDjmsvdAH90Q7oKmhNeTdwJdj2FX84adLzo=@entry_node:14626"
], ],
"port": 14626, "port": 14626
"version": 1
}, },
"dashboard": { "dashboard": {
"bindAddress": "0.0.0.0:8081", "bindAddress": "0.0.0.0:8081",
...@@ -30,6 +29,12 @@ ...@@ -30,6 +29,12 @@
"database": { "database": {
"directory": "mainnetdb" "directory": "mainnetdb"
}, },
"drng": {
"instanceId": 1,
"threshold": 3,
"distributedPubKey": "",
"committeeMembers": []
},
"gossip": { "gossip": {
"port": 14666 "port": 14666
}, },
...@@ -39,8 +44,7 @@ ...@@ -39,8 +44,7 @@
"disableStacktrace": false, "disableStacktrace": false,
"encoding": "console", "encoding": "console",
"outputPaths": [ "outputPaths": [
"stdout", "stdout"
"goshimmer.log"
], ],
"disableEvents": true, "disableEvents": true,
"remotelog": { "remotelog": {
...@@ -63,4 +67,4 @@ ...@@ -63,4 +67,4 @@
}, },
"bindAddress": "0.0.0.0:8080" "bindAddress": "0.0.0.0:8080"
} }
} }
\ No newline at end of file
...@@ -2,56 +2,57 @@ version: "3.5" ...@@ -2,56 +2,57 @@ version: "3.5"
services: services:
entry_node: entry_node:
container_name: entry_node
image: golang:1.14
entrypoint: /go/bin/main
command: > command: >
--config-dir=/tmp
--database.directory=/tmp/mainnetdb
--autopeering.seed=uuDCzsjyLNQ17/7fWKPNMYmr4IWuaVRf7qKqRL0v/6c= --autopeering.seed=uuDCzsjyLNQ17/7fWKPNMYmr4IWuaVRf7qKqRL0v/6c=
--autopeering.entryNodes= --autopeering.entryNodes=
--analysis.server.bindAddress=0.0.0.0:1888 --analysis.server.bindAddress=0.0.0.0:1888
--node.enablePlugins=analysis-server,analysis-webinterface --node.enablePlugins=analysis-server,analysis-webinterface
--node.disablePlugins=portcheck,dashboard,webapi,webapibroadcastdataendpoint,webapifindtransactionhashesendpoint,webapigetneighborsendpoint,webapigettransactionobjectsbyhashendpoint,webapigettransactiontrytesbyhashendpoint --node.disablePlugins=portcheck,dashboard,analysis-client,gossip,drng,issuer,sync,metrics,messagelayer,webapi,webapibroadcastdataendpoint,webapifindtransactionhashesendpoint,webapigetneighborsendpoint,webapigettransactionobjectsbyhashendpoint,webapigettransactiontrytesbyhashendpoint
container_name: entry_node
image: iotaledger/goshimmer
build:
context: ../..
volumes: volumes:
- ./config.docker.json:/config.json:ro - ./config.docker.json:/tmp/config.json:ro
- goshimmer-cache:/go
ports: ports:
- "127.0.0.1:9000:9000/tcp" # autopeering visualizer - "127.0.0.1:9000:9000/tcp" # autopeering visualizer
expose: expose:
- "1888/tcp" # analysis server (within Docker network) - "1888/tcp" # analysis server (within Docker network)
networks:
- integration-test
peer_master: peer_master:
command: --node.enablePlugins=bootstrap
container_name: peer_master container_name: peer_master
image: iotaledger/goshimmer image: golang:1.14
build: entrypoint: /go/bin/main
context: ../.. command: >
--config-dir=/tmp
--database.directory=/tmp/mainnetdb
--node.enablePlugins=bootstrap
volumes: volumes:
- ./config.docker.json:/config.json:ro - ./config.docker.json:/tmp/config.json:ro
- goshimmer-cache:/go
ports: ports:
- "127.0.0.1:8080:8080/tcp" # web API - "127.0.0.1:8080:8080/tcp" # web API
- "127.0.0.1:8081:8081/tcp" # dashboard - "127.0.0.1:8081:8081/tcp" # dashboard
depends_on: depends_on:
- entry_node - entry_node
networks:
- integration-test
peer_replica: peer_replica:
command: --node.disablePlugins=dashboard,portcheck image: golang:1.14
image: iotaledger/goshimmer entrypoint: /go/bin/main
build: command: >
context: ../.. --config-dir=/tmp
--database.directory=/tmp/mainnetdb
--node.disablePlugins=dashboard,portcheck
volumes: volumes:
- ./config.docker.json:/config.json:ro - ./config.docker.json:/tmp/config.json:ro
- goshimmer-cache:/go
expose: expose:
- "8080/tcp" # web API (within Docker network) - "8080/tcp" # web API (within Docker network)
depends_on: depends_on:
- entry_node - entry_node
networks:
- integration-test
networks: volumes:
integration-test: goshimmer-cache:
driver: bridge name: goshimmer-cache
name: integration-test
#!/bin/bash
if [[ $# -eq 0 ]] ; then
echo 'Call with ./run replicas'
exit 0
fi
REPLICAS=$1
echo "Build GoShimmer"
docker-compose -f builder/docker-compose.builder.yml up
echo "Run GoShimmer network"
docker-compose up --scale peer_replica=$REPLICAS
echo "Clean up docker network"
docker-compose down
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment