set memory and cpu limits on the container

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2020-03-26 14:13:23 +01:00
parent 2923405a9d
commit eb798800c7
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
2 changed files with 14 additions and 0 deletions

View File

@ -19,6 +19,12 @@ beacon_node_metrics_port: 9200
# rpc / administrative
beacon_node_rpc_port: 9900
# resource limits, mem in MB
beacon_node_cpu_limit: 0.60
beacon_node_mem_limit: '{{ (ansible_memtotal_mb * 0.6) | int }}'
beacon_node_cpu_reserve: 0.20
beacon_node_mem_reserve: '{{ (ansible_memtotal_mb * 0.2) | int }}'
# general container management
compose_state: 'present'
compose_recreate: 'smart'

View File

@ -15,6 +15,14 @@
container_name: '{{ beacon_node_cont_name }}'
image: '{{ beacon_node_cont_image }}'
restart: 'always'
deploy:
resources:
limits:
cpus: '{{ beacon_node_cpu_limit | string }}'
memory: '{{ beacon_node_mem_limit }}M'
reservations:
cpus: '{{ beacon_node_cpu_reserve | string }}'
memory: '{{ beacon_node_mem_reserve }}M'
ports:
- '127.0.0.1:{{ beacon_node_rpc_port }}:{{ beacon_node_rpc_port }}/tcp'
- '{{ beacon_node_metrics_port }}:{{ beacon_node_metrics_port }}/tcp'