Skip to content

Commit efc808e

Browse files
committed
AWS Setup md
Signed-off-by: Effi-S <effi.szt@gmail.com>
1 parent b1591b6 commit efc808e

2 files changed

Lines changed: 169 additions & 15 deletions

File tree

cmd/benchmarking/plotly_plot_node.py

Lines changed: 57 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import re
2-
import sys
2+
import os
33
from pathlib import Path
44
from typing import Any
55
import pandas as pd
@@ -10,7 +10,7 @@
1010

1111
IGNORE_COLS = {"bench", "workers", "tps",
1212
"iterations", "ns/op", "B/op", "allocs/op"}
13-
DEFAULT_BENCH_DIR = "bench2"
13+
DEFAULT_BENCH_DIR = "bench"
1414

1515

1616
def _is_number(s: str) -> bool:
@@ -75,6 +75,10 @@ def simple_parser(path: Path) -> pd.DataFrame:
7575
df[f"{label} (ms)"] = df[col] / 1e6
7676
df = df.drop(columns=[col])
7777

78+
if 'tps' in df.columns and 'workers' in df.columns:
79+
# Little's Law (latency = concurrency / throughput)
80+
df['avg (ms)'] = df['workers'] * 1000 / df['tps']
81+
7882
return df
7983

8084

@@ -102,13 +106,21 @@ def _parse_ms(s: str) -> float:
102106
raise ValueError(f"unknown unit: {unit}")
103107

104108

105-
LATENCY_KEYS = {'P5': 'p5 (ms)', 'P95': 'p95 (ms)', 'P99': 'p99 (ms)'}
109+
LATENCY_KEYS = {
110+
'P50 (Median)': 'p50 (ms)',
111+
'P5': 'p5 (ms)',
112+
'P95': 'p95 (ms)',
113+
'P99': 'p99 (ms)',
114+
}
115+
DISPLAY_LATENCY = {'avg (ms)', 'p50 (ms)', 'p95 (ms)'}
116+
WORKERS_RE = re.compile(r'^Workers\s+(\d+)')
106117

107118

108-
def parse_parallel_log(path: Path) -> pd.DataFrame:
119+
def parse_parallel_log(path: Path, default_bench: str | None = None) -> pd.DataFrame:
109120
text = ANSI_ESCAPE_RE.sub('', path.read_text())
110121
rows: list[dict] = []
111122
current: dict = {}
123+
has_run_lines = bool(PARALLEL_RUN_RE.search(text))
112124

113125
for line in text.splitlines():
114126
line = line.strip()
@@ -129,6 +141,18 @@ def parse_parallel_log(path: Path) -> pd.DataFrame:
129141
current[k] = v
130142
continue
131143

144+
if not has_run_lines:
145+
m = WORKERS_RE.match(line)
146+
if m:
147+
workers = int(m.group(1))
148+
if current:
149+
rows.append(current)
150+
current = {
151+
'bench': default_bench or path.stem,
152+
'workers': workers,
153+
}
154+
continue
155+
132156
m = PARALLEL_THROUGHPUT_RE.match(line)
133157
if m:
134158
current['tps'] = float(m.group(1))
@@ -157,31 +181,30 @@ def has_multi_nc(df: pd.DataFrame) -> bool:
157181

158182
def _tps_fig(df, color_col, title):
159183
fig = px.line(df, x='workers', y='tps', color=color_col,
184+
symbol=color_col,
160185
markers=True, title=title,
161-
labels={'workers': 'Workers', 'tps': 'TPS', color_col: ''})
162-
# fig.update_xaxes(
163-
# showgrid=True,
164-
# # griddash='dash',
165-
# )
186+
labels={'workers': 'Workers', 'tps': 'TPS', color_col: ''},
187+
symbol_sequence=SHAPES)
166188
fig.update_yaxes(
167-
# showgrid=True,
168189
nticks=25,
169-
# griddash='dash',
170190
)
171191
fig.update_layout(template='plotly_white',
172192
hovermode='x unified')
173193
return fig
174194

175195

176196
def _latency_fig(df, color_col, dash_col, title):
177-
latency_cols = [c for c in df.columns if c.endswith('(ms)')]
197+
latency_cols = [c for c in df.columns if c in DISPLAY_LATENCY]
178198
if not latency_cols:
179199
return None
180200
melted = df.melt(id_vars=[color_col, 'workers'], value_vars=latency_cols,
181201
var_name='percentile', value_name='latency')
202+
dash_map = {'avg (ms)': 'dash', 'p50 (ms)': 'solid', 'p95 (ms)': 'dot'}
182203
fig = px.line(melted, x='workers', y='latency',
183204
color=color_col, line_dash=dash_col, markers=True, title=title,
184-
labels={'workers': 'Workers', 'latency': 'Latency (ms)', color_col: ''})
205+
labels={'workers': 'Workers',
206+
'latency': 'Latency (ms)', color_col: ''},
207+
line_dash_map=dash_map)
185208
fig.update_layout(template='plotly_white', hovermode='x unified')
186209
return fig
187210

@@ -233,6 +256,9 @@ def parse_combined(dfs: dict[str, pd.DataFrame]):
233256
return dct
234257

235258

259+
SHAPES = ['circle', 'square', 'diamond', 'cross', 'hexagon', 'star']
260+
261+
236262
def make_combined_figures(dfs, local_dfs):
237263
figs = {"_All": None}
238264
all_dfs = []
@@ -265,12 +291,28 @@ def make_combined_figures(dfs, local_dfs):
265291
return figs
266292

267293

268-
def main():
294+
def _get_dir():
295+
def_dir = Path(os.environ.get("DEF_BENCH", DEFAULT_BENCH_DIR))
296+
269297
with st.sidebar:
270298
directory = st.text_input(
271-
"Directory", value=DEFAULT_BENCH_DIR, key="benchdir")
299+
"Directory", value=str(def_dir) if def_dir.exists() else "", key="benchdir")
300+
os.environ["DEF_BENCH"] = directory
301+
302+
if not directory:
303+
st.info(f"Please input a Folder in the Sidebar")
304+
return None
272305
directory = Path(directory)
306+
if not directory.exists():
307+
st.error(f"Directory `{directory}` does not exist")
308+
return None
309+
return directory
273310

311+
312+
def main():
313+
directory = _get_dir()
314+
if not directory:
315+
return
274316
single = {}
275317

276318
for path in sorted(directory.glob("*.log")):
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
## SSH
2+
Add ssh pubkey of server to client `known_hosts`
3+
4+
## Server
5+
```bash
6+
GOGC=10000 go run ./server/
7+
```
8+
9+
## Client
10+
1. Rsync:
11+
12+
```bash
13+
rsync -avz AWS-128:~/effi/fabric-token-sdk/token/core/zkatdlog/nogh/v1/validator/bench/transfer_service/out/ ./out
14+
```
15+
16+
2. replacing ip
17+
18+
```bash
19+
sed 's#127.0.0.1#ec2-54-90-141-176.compute-1.amazonaws.com#g' ./out/testdata/fsc/nodes/test-node.0/client-config.yaml -i
20+
```
21+
22+
```bash
23+
GOGC=10000 nohup go run ./client/ -benchtime=30s -count=5 -workloads=transfer-service -cpu=1,2,4,8,16,32,48,64 -numConn=1,2,4,8 2>&1 | tee out.txt &
24+
```
25+
26+
27+
# Prometheus Setup
28+
1. Download
29+
30+
```bash
31+
sudo yum update -y && sudo yum install -y wget
32+
wget https://github.com/prometheus/prometheus/releases/download/v2.52.0/prometheus-2.52.0.linux-amd64.tar.gz
33+
tar xvf prometheus-2.52.0.linux-amd64.tar.gz
34+
sudo mv prometheus-2.52.0.linux-amd64/prometheus /usr/local/bin/
35+
sudo mv prometheus-2.52.0.linux-amd64/promtool /usr/local/bin/
36+
```
37+
38+
2. Make config dir
39+
40+
```bash
41+
sudo mkdir /etc/prometheus
42+
sudo mkdir /var/lib/prometheus
43+
sudo cp prometheus-2.52.0.linux-amd64/prometheus.yml /etc/prometheus/
44+
```
45+
46+
3. Configure Prometheus for node exporter
47+
```bash
48+
sudo nano /etc/prometheus/prometheus.yml
49+
```
50+
```yaml
51+
scrape_configs:
52+
- job_name: "node"
53+
static_configs:
54+
- targets: ["localhost:9100"]
55+
```
56+
4. Add Prometheus user
57+
```bash
58+
sudo useradd --no-create-home --shell /bin/false prometheus
59+
sudo chown -R prometheus:prometheus /etc/prometheus
60+
sudo chown -R prometheus:prometheus /var/lib/prometheus
61+
sudo chown -R $(whoami):$(whoami) /var/lib/prometheus
62+
```
63+
64+
4. Run Prometheus
65+
```bash
66+
prometheus \
67+
--config.file=/etc/prometheus/prometheus.yml \
68+
--storage.tsdb.path=/var/lib/prometheus
69+
```
70+
71+
# Install Node Exporter
72+
```bash
73+
wget https://github.com/prometheus/node_exporter/releases/latest/download/node_exporter-1.10.2.linux-amd64.tar.gz
74+
tar xvf node_exporter-1.10.2.linux-amd64.tar.gz
75+
cd node_exporter-1.10.2.linux-amd64
76+
sudo mv node_exporter /usr/local/bin/
77+
```
78+
Run it
79+
```bash
80+
node_exporter # see http://<EC2-IP>:9100/metrics
81+
```
82+
(verify scraping at: `http://<EC2-IP>:9090/targets`)
83+
84+
85+
# Install Graphana
86+
```bash
87+
sudo yum install grafana -y
88+
```
89+
Start Graphana
90+
```bash
91+
sudo systemctl daemon-reexec
92+
sudo systemctl start grafana-server
93+
sudo systemctl enable grafana-server
94+
```
95+
96+
Now a vailable at: `http://<EC2-IP>:3000`
97+
user/pwd: `admin/admin`
98+
99+
## Setup dashboard
100+
In Grafana UI > Go to Dashboards > Click Import
101+
102+
Enter dashboard ID:`1860`
103+
104+
In `http://<EC2-IP>:3000/connections/datasources`:
105+
Add prometheus > Save and Test
106+
107+
if you get:
108+
```bash
109+
Post "http://127.0.0.1:9090/api/v1/query": dial tcp 127.0.0.1:9090: connect: permission denied - There was an error returned querying the Prometheus API.
110+
```
111+
112+
Do `sudo setenforce 0`

0 commit comments

Comments
 (0)