Skip to content

Commit 470a31f

Browse files
authored
fix(docker): update jvm heap size (#30)
1 parent 4bf0c3d commit 470a31f

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ metric_monitor/datadir
1414
private_net/datadir
1515
tron-docker.iml
1616
bin/
17+
/single_node/output-directory/
18+
/metric_monitor/logs/
19+
/private_net/logs/

metric_monitor/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Please download and install the latest version of Docker from the official Docke
1111
* Docker Installation for [Windows](https://docs.docker.com/docker-for-windows/install/)
1212
* Docker Installation for [Linux](https://docs.docker.com/desktop/setup/install/linux/)
1313

14-
Then check the Docker resource settings to ensure it has at least 16GB of memory.
14+
Then check the Docker resource settings to ensure it has at least 16GB of memory per FullNode container.
1515

1616
## Quick start
1717
Download the `tron-docker` repository, enter the `metric` directory, and start the services defined in [docker-compose.yml](./docker-compose.yml) using the following command:

metric_monitor/docker-compose.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ services:
1515
volumes:
1616
- ../conf:/java-tron/conf
1717
- ./datadir:/java-tron/data # mount a local directory to make the blocks data persistent.
18+
- ./logs:/java-tron/logs
1819
command: >
19-
-jvm "{-Xmx16g -Xms12g -XX:+UseConcMarkSweepGC -XX:+PrintGC}" -c ./conf/main_net_config.conf -d /java-tron/data
20+
-jvm "{-Xmx12g -Xmn2g -XX:+UseConcMarkSweepGC -XX:+PrintGC -Xloggc:./logs/gc.log }" -c ./conf/main_net_config.conf -d /java-tron/data
2021
2122
prometheus:
2223
image: prom/prometheus:latest

private_net/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ Please download and install the latest version of Docker from the official Docke
2020

2121
Then check the Docker resource settings to ensure it has at least 3GB of memory per TRON node.
2222

23-
**Notice:** The actual memory consumption for a FullNode depends heavily on your configurations and use case. Factors such as block generation frequency, transactions per second (TPS), and external API request QPS can significantly impact memory usage. To help you get started quickly, the memory consumption under the following guidance should remain below **3GB**. However, for a TRON Mainnet Super Representative (SR) FullNode capable of supporting **2000 TPS**, the maximum memory consumption can reach up to **12GB**.
23+
**Notice:** The actual memory consumption for a FullNode depends heavily on your configurations and use case. Factors such as block generation frequency, transactions per second (TPS), and external API request QPS can significantly impact memory usage. To help you get started quickly, the memory consumption under the following guidance is within **3GB**. However, for a TRON Mainnet Super Representative (SR) FullNode capable of supporting **2000 TPS**, the memory resource per FullNode container should set above **16GB**.
2424

2525

2626
## Quick-Start using Docker

private_net/docker-compose.yml

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,16 @@ services:
88
deploy:
99
resources:
1010
limits:
11-
memory: 12g
11+
memory: 16g
1212
ports:
1313
- "8090:8090" # for external http API request
1414
- "50051:50051" # for external rpc API request
1515
volumes:
1616
- ../conf:/java-tron/conf
1717
- ./datadir:/java-tron/data # mount a local directory to make the blocks data persistent.
18+
- ./logs/tron-witness1:/java-tron/logs # map to host logs
1819
command: >
19-
-jvm "{-Xmx12g -Xms3g -XX:+UseConcMarkSweepGC}" -c /java-tron/conf/private_net_config_witness1.conf -d /java-tron/data -w
20+
-jvm "{-Xmx12g -Xmn2g -XX:+UseConcMarkSweepGC -Xloggc:./logs/gc.log}" -c /java-tron/conf/private_net_config_witness1.conf -d /java-tron/data -w
2021
2122
# tron-witness2:
2223
# image: tronprotocol/java-tron:latest
@@ -26,11 +27,12 @@ services:
2627
# deploy:
2728
# resources:
2829
# limits:
29-
# memory: 12g
30+
# memory: 16g
3031
# volumes:
3132
# - ../conf:/java-tron/conf
33+
# - ./logs/tron-witness2:/java-tron/logs
3234
# command: >
33-
# -jvm "{-Xmx12g -Xms3g -XX:+UseConcMarkSweepGC}"
35+
# -jvm "{-Xmx12g -Xmn2g -XX:+UseConcMarkSweepGC -Xloggc:./logs/gc.log}"
3436
# -c /java-tron/conf/private_net_config_witness2.conf
3537
# -w
3638
tron-node1:
@@ -41,11 +43,12 @@ services:
4143
deploy:
4244
resources:
4345
limits:
44-
memory: 12g
46+
memory: 16g
4547
volumes:
4648
- ../conf:/java-tron/conf
49+
- ./logs/tron-node1:/java-tron/logs
4750
command: >
48-
-jvm "{-Xmx12g -Xms3g -XX:+UseConcMarkSweepGC}" -c /java-tron/conf/private_net_config_others.conf
51+
-jvm "{-Xmx12g -Xmn2g -XX:+UseConcMarkSweepGC -Xloggc:./logs/gc.log}" -c /java-tron/conf/private_net_config_others.conf
4952
5053
# tron-node2:
5154
# image: tronprotocol/java-tron:latest
@@ -55,11 +58,12 @@ services:
5558
# deploy:
5659
# resources:
5760
# limits:
58-
# memory: 12g
61+
# memory: 16g
5962
# volumes:
6063
# - ../conf:/java-tron/conf
64+
# - ./logs/tron-node2:/java-tron/logs
6165
# command: >
62-
# -jvm "{-Xmx12g -Xms3g -XX:+UseConcMarkSweepGC}"
66+
# -jvm "{-Xmx12g -Xmn2g -XX:+UseConcMarkSweepGC -Xloggc:./logs/gc.log}"
6367
# -c /java-tron/conf/private_net_config_others.conf
6468
networks:
6569
tron_private_network:

single_node/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Please download and install the latest version of Docker from the official Docke
2323
* Docker Installation for [Windows](https://docs.docker.com/docker-for-windows/install/)
2424
* Docker Installation for [Linux](https://docs.docker.com/desktop/setup/install/linux/)
2525

26-
Then check the Docker resource settings to ensure it has at least 16GB of memory.
26+
Then check the Docker resource settings to ensure it has at least 16GB of memory per FullNode container.
2727

2828
## Get Docker image
2929
There are two ways to obtain the TRON image:
@@ -69,7 +69,7 @@ docker run --name tron-node -d -p 8090:8090 -p 8091:8091 -p 18888:18888 -p 18888
6969
-v /host/path/datadir:/java-tron/data \
7070
-v /host/path/logs:/java-tron/logs \
7171
tronprotocol/java-tron \
72-
-jvm "{-Xmx16g -Xms12g -XX:+UseConcMarkSweepGC}" \
72+
-jvm "{-Xmx12g -XX:+UseConcMarkSweepGC}" \
7373
-c /java-tron/conf/config-localtest.conf \
7474
-d /java-tron/data \
7575
-w
@@ -79,7 +79,7 @@ In the example above, the host file `/host/path/conf/config-localtest.conf` will
7979
Logs generated by docker container will be mapped to your `/host/path/logs`.
8080

8181
Flags after `tronprotocol/java-tron` are used for java-tron start-up arguments:
82-
- `-jvm` used for java virtual machine, the parameters must be enclosed in double quotes and braces. `"{-Xmx16g -Xms12g}"` sets the maximum heap size to 16GB. If you want to set up a long run FullNode, please use the best practice jvm flags with `"{-Xmx16g -Xms12g XX:ReservedCodeCacheSize=256m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -XX:MaxDirectMemorySize=1G -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log -XX:+UseConcMarkSweepGC -XX:NewRatio=2 -XX:+CMSScavengeBeforeRemark -XX:+ParallelRefProcEnabled -XX:+HeapDumpOnOutOfMemoryError -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70}"`.
82+
- `-jvm` used for java virtual machine, the parameters must be enclosed in double quotes and braces. `"{-Xmx12g}"` sets the maximum heap size to 12GB. If you want to set up a long run FullNode, please use the best practice jvm flags with `"{-Xmx12g -Xmn2g XX:ReservedCodeCacheSize=256m -XX:MetaspaceSize=256m -XX:MaxMetaspaceSize=512m -XX:MaxDirectMemorySize=1G -XX:+PrintGCDetails -XX:+PrintGCDateStamps -Xloggc:gc.log -XX:+UseConcMarkSweepGC -XX:NewRatio=2 -XX:+CMSScavengeBeforeRemark -XX:+ParallelRefProcEnabled -XX:+HeapDumpOnOutOfMemoryError -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70}"`.
8383
- `-c` defines the configuration file to use.
8484
- `-d` defines the database file to use. You can mount a directory for `datadir` with snapshots. This can save time by syncing from a near-latest block number. Please refer to [**Fullnode and Lite-Fullnode**](https://tronprotocol.github.io/documentation-en/using_javatron/backup_restore/#fullnode-data-snapshot) for Mainnet data. For the Nile testnet, you can download the snapshot [here](https://database.nileex.io/).
8585
- `-w` means to start as a witness. You need to fill the `localwitness` field with private keys in configure file. Refer to the [**Run as Witness**](https://tronprotocol.github.io/documentation-en/using_javatron/installing_javatron/#startup-a-fullnode-that-produces-blocks). If you want to use keystore + password method, make sure the keystore is inside the mounted directory and remove `-d` to interact with console for password input.

0 commit comments

Comments
 (0)