Skip to content

Commit ad2f761

Browse files
committed
Some cleanups + playground readme
1 parent 2dce929 commit ad2f761

4 files changed

Lines changed: 96 additions & 22 deletions

File tree

playground/README.md

Lines changed: 80 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,82 @@
1-
# Playground
1+
# FDB Playground
22

3-
This directory is used for testing and playing around with different things. Idea is to have a place where we can spawn
4-
as many as possible nodes we want and see them in grafana dashboard how they behave. Behaviour include:
3+
The playground provides a flexible environment for testing and benchmarking the FDB P2P network under various conditions. It allows you to spawn multiple nodes with different roles and configurations, run predefined strategies against them, and monitor their behavior through observability tools like Grafana and OpenTelemetry.
54

6-
- Network, latencies and availability
7-
- RPC
8-
- Raw TCP and Capn Proto
5+
## Features
6+
7+
- Spawn multiple P2P nodes with customizable roles and configurations
8+
- Monitor network latencies, throughput, and node availability
9+
- Test RPC communications between nodes
10+
- Evaluate raw TCP performance and CapnProto serialization
11+
- Benchmark write operations with configurable concurrency and data sizes
12+
- Track per-node metrics with enhanced observability
13+
- Automatic clean shutdown when tests complete
14+
15+
## Usage
16+
17+
### Basic Command Structure
18+
19+
```bash
20+
# General syntax
21+
fdb playground [options] <strategy> [strategy-specific-options]
22+
23+
# Examples
24+
fdb playground --nodes 5 --base-port 9000 write --workers 20 --data-size 100 --total-ops 5000
25+
```
26+
27+
### Global Options
28+
29+
- `--nodes <number>`: Number of nodes to create (default: 3)
30+
- `--base-port <port>`: Starting port number for node communication (default: 8000)
31+
- `--strategy <name>`: Name of the strategy to run (can also be specified as a command)
32+
- `--log-level <level>`: Logging level (debug, info, warn, error)
33+
34+
### Available Strategies
35+
36+
#### Write Strategy
37+
38+
The write strategy tests write operations to the P2P network with configurable parameters:
39+
40+
```bash
41+
fdb playground write [options]
42+
```
43+
44+
Options:
45+
- `--target-node <index>`: Index of the node to send writes to (default: 0)
46+
- `--workers <number>`: Number of concurrent workers (default: 10)
47+
- `--data-size <kb>`: Size of data to write in KB (default: 10)
48+
- `--ops-per-sec <number>`: Target operations per second (default: 100)
49+
- `--total-ops <number>`: Total number of operations (default: 1000)
50+
51+
## Observability
52+
53+
Each node in the playground is assigned a unique identifier (e.g., `playground_peer_0`) that is included in:
54+
55+
1. All log entries
56+
2. Metrics reported to Prometheus
57+
3. Traces exported to OpenTelemetry
58+
59+
This allows for detailed per-node analysis in Grafana dashboards and other observability tools.
60+
61+
## Examples
62+
63+
### Run a Write Test with 5 Nodes
64+
65+
```bash
66+
# Create 5 nodes and run a write test with 20 workers, 100KB data size, and 5000 total operations
67+
fdb playground --nodes 5 write --workers 20 --data-size 100 --total-ops 5000
68+
```
69+
70+
### Custom Port Configuration
71+
72+
```bash
73+
# Start with base port 9000 instead of default 8000
74+
fdb playground --base-port 9000 write
75+
```
76+
77+
### Detailed Logging
78+
79+
```bash
80+
# Enable debug-level logging
81+
fdb playground --log-level debug write
82+
```

playground/entrypoint.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ func Run(cliCtx *cli.Context, cfg Config) error {
136136
}
137137

138138
// Parse CLI arguments using the strategy's argument mappings
139-
args := strategies.ParseCliArgs(cliCtx, strategyInfo)
139+
args := strategies.ParseArgs(cliCtx, strategyInfo)
140140

141141
// Create a channel to signal when the strategy is done
142142
strategyCh := make(chan error, 1)

playground/strategies/strategies.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ import (
1010

1111
// ArgMapping defines how CLI flags map to strategy parameters
1212
type ArgMapping struct {
13-
// CliFlag is the name of the flag in the CLI (e.g. "data-size")
14-
CliFlag string
13+
// Flag is the name of the flag in the CLI (e.g. "data-size")
14+
Flag string
1515

1616
// ParamKey is the key in the args map passed to the strategy (e.g. "data_size_kb")
1717
ParamKey string
@@ -65,8 +65,8 @@ type Strategy interface {
6565
CompletionCh() <-chan struct{}
6666
}
6767

68-
// ParseCliArgs converts CLI context args to strategy args based on the mappings
69-
func ParseCliArgs(cliCtx *cli.Context, info Info) map[string]any {
68+
// ParseArgs converts CLI context args to strategy args based on the mappings
69+
func ParseArgs(cliCtx *cli.Context, info Info) map[string]any {
7070
args := make(map[string]any)
7171

7272
// Add default values from DefaultArgs
@@ -76,20 +76,20 @@ func ParseCliArgs(cliCtx *cli.Context, info Info) map[string]any {
7676

7777
// Parse args from CLI flags based on the mappings
7878
for _, mapping := range info.ArgMappings {
79-
if cliCtx.IsSet(mapping.CliFlag) {
79+
if cliCtx.IsSet(mapping.Flag) {
8080
// Get the value based on type inference
8181
switch mapping.DefaultValue.(type) {
8282
case int:
83-
args[mapping.ParamKey] = cliCtx.Int(mapping.CliFlag)
83+
args[mapping.ParamKey] = cliCtx.Int(mapping.Flag)
8484
case string:
85-
args[mapping.ParamKey] = cliCtx.String(mapping.CliFlag)
85+
args[mapping.ParamKey] = cliCtx.String(mapping.Flag)
8686
case bool:
87-
args[mapping.ParamKey] = cliCtx.Bool(mapping.CliFlag)
87+
args[mapping.ParamKey] = cliCtx.Bool(mapping.Flag)
8888
case float64:
89-
args[mapping.ParamKey] = cliCtx.Float64(mapping.CliFlag)
89+
args[mapping.ParamKey] = cliCtx.Float64(mapping.Flag)
9090
default:
9191
// For other types, just use the string value
92-
args[mapping.ParamKey] = cliCtx.String(mapping.CliFlag)
92+
args[mapping.ParamKey] = cliCtx.String(mapping.Flag)
9393
}
9494
}
9595
}

playground/strategies/write.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -269,35 +269,35 @@ func (s *WriteStrategy) Info() Info {
269269
},
270270
ArgMappings: []ArgMapping{
271271
{
272-
CliFlag: "target-node",
272+
Flag: "target-node",
273273
ParamKey: "target_node",
274274
Description: "Index of the node to send writes to (default 0 = first node)",
275275
DefaultValue: 0,
276276
Required: false,
277277
},
278278
{
279-
CliFlag: "workers",
279+
Flag: "workers",
280280
ParamKey: "workers",
281281
Description: "Number of concurrent workers for write operations (optimized with XOR key distribution)",
282282
DefaultValue: 10,
283283
Required: false,
284284
},
285285
{
286-
CliFlag: "data-size",
286+
Flag: "data-size",
287287
ParamKey: "data_size_kb",
288288
Description: "Size of data to write in KB (uses optimized TCP streaming with 128KB buffer)",
289289
DefaultValue: 10,
290290
Required: false,
291291
},
292292
{
293-
CliFlag: "ops-per-sec",
293+
Flag: "ops-per-sec",
294294
ParamKey: "ops_per_sec",
295295
Description: "Target operations per second across all workers",
296296
DefaultValue: 100,
297297
Required: false,
298298
},
299299
{
300-
CliFlag: "total-ops",
300+
Flag: "total-ops",
301301
ParamKey: "total_ops",
302302
Description: "Total number of operations to perform",
303303
DefaultValue: 1000,

0 commit comments

Comments
 (0)