Skip to content

Commit

Permalink
Adds withHighCapacityExplorer config and node updates
Browse files Browse the repository at this point in the history
  • Loading branch information
johnalotoski committed May 21, 2020
1 parent 419fb2c commit 3d8ccc6
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 9 deletions.
6 changes: 3 additions & 3 deletions clusters/cardano.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
, t3-xlarge # High load relay
, m5ad-xlarge # Test node
, xlarge-monitor # Standard monitor
, t3-2xlarge-monitor # High capacity monitor
, t3-2xlarge-monitor # High capacity monitor, explorer
, ...
}:
with pkgs;
Expand Down Expand Up @@ -91,10 +91,10 @@ let
_file = ./cardano.nix;
deployment.ec2 = {
region = def.region or "eu-central-1";
ebsInitialRootDiskSize = 100;
ebsInitialRootDiskSize = if globals.withHighCapacityExplorer then 1000 else 100;
};
imports = [
xlarge
(if globals.withHighCapacityExplorer then t3-2xlarge-monitor else xlarge)
cardano-ops.roles.explorer
]
# TODO: remove module when the new explorer is available
Expand Down
2 changes: 1 addition & 1 deletion deployments/cardano-aws.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ let
t3-xlarge = aws.t3-xlarge; # High load relay
m5ad-xlarge = aws.m5ad-xlarge; # Test node
xlarge-monitor = aws.t3a-xlargeMonitor; # Standard monitor
t3-2xlarge-monitor = aws.t3-2xlargeMonitor; # High capacity monitor
t3-2xlarge-monitor = aws.t3-2xlargeMonitor; # High capacity monitor, explorer
};

nodes = filterAttrs (name: node:
Expand Down
1 change: 1 addition & 0 deletions globals-defaults.nix
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ in {
initialPythonExplorerDBSyncDone = false;

withHighCapacityMonitoring = false;
withHighCapacityExplorer = false;
withHighLoadRelays = false;

environments = pkgs.iohkNix.cardanoLib.environments;
Expand Down
1 change: 1 addition & 0 deletions globals-mainnet.nix
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pkgs: {

withCardanoDBExtended = true;
withHighCapacityMonitoring = true;
withHighCapacityExplorer = true;
withHighLoadRelays = true;

initialPythonExplorerDBSyncDone = true;
Expand Down
38 changes: 34 additions & 4 deletions modules/cardano-postgres.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,44 @@ in {
package = postgresql_12;
dataDir = mkIf (cfg.postgresqlDataDir != null) cfg.postgresqlDataDir;
enableTCPIP = false;
extraConfig = ''
extraConfig = if globals.withHighCapacityExplorer then ''
# Optimized for:
# DB Version: 12
# OS Type: linux
# DB Type: web
# Total Memory (RAM): 16 GB
# Total Memory (RAM): 16 GB (half the RAM of high capacity explorer)
# CPUs num: 8 (high capacity explorer vCPUs)
# Connections num: 200
# Data Storage: ssd
# Suggested optimization for
# other configurations can be
# found at:
# https://pgtune.leopard.in.ua/
max_connections = 200
shared_buffers = 4GB
effective_cache_size = 12GB
maintenance_work_mem = 1GB
checkpoint_completion_target = 0.7
wal_buffers = 16MB
default_statistics_target = 100
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem = 5242kB
min_wal_size = 1GB
max_wal_size = 4GB
max_worker_processes = 8
max_parallel_workers_per_gather = 4
max_parallel_workers = 8
max_parallel_maintenance_workers = 4
'' else '';
# DB Version: 12
# OS Type: linux
# DB Type: web
# Total Memory (RAM): 8 GB (half the RAM of regular explorer)
# CPUs num: 4 (explorer vCPUs)
# Connections num: 200
# Data Storage: ssd
max_connections = 200
shared_buffers = 2GB
effective_cache_size = 6GB
maintenance_work_mem = 512MB
Expand All @@ -46,9 +72,13 @@ in {
default_statistics_target = 100
random_page_cost = 1.1
effective_io_concurrency = 200
work_mem = 10485kB
work_mem = 5242kB
min_wal_size = 1GB
max_wal_size = 2GB
max_wal_size = 4GB
max_worker_processes = 4
max_parallel_workers_per_gather = 2
max_parallel_workers = 4
max_parallel_maintenance_workers = 2
'';
};
};
Expand Down
14 changes: 13 additions & 1 deletion roles/explorer.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,10 @@ in {
services.cardano-node = {
enable = true;
inherit nodeId;
extraArgs = [ "+RTS" "-N2" "-A10m" "-qg" "-qb" "-M3G" "-RTS" ];
extraArgs = lib.mkForce (if globals.withHighCapacityExplorer then
[ "+RTS" "-N2" "-A10m" "-qg" "-qb" "-M10G" "-RTS" ]
else
[ "+RTS" "-N2" "-A10m" "-qg" "-qb" "-M3G" "-RTS" ]);
environment = globals.environmentName;
environments = {
"${globals.environmentName}" = globals.environmentConfig;
Expand All @@ -60,6 +63,9 @@ in {
inherit cardanoNodePkgs;
});

systemd.services.cardano-node.serviceConfig.MemoryMax = lib.mkForce
(if globals.withHighCapacityExplorer then "14G" else "3.5G");

services.cardano-db-sync = {
enable = true;
cluster = globals.environmentName;
Expand Down Expand Up @@ -112,6 +118,12 @@ in {
services.nginx = {
enable = true;
package = nginxExplorer;
eventsConfig = ''
worker_connections 4096;
'';
appendConfig = ''
worker_rlimit_nofile 16384;
'';
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
Expand Down

0 comments on commit 3d8ccc6

Please sign in to comment.