1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
//! Spam peers deployed to AWS EC2 with random messages.
//!
//! # Setup
//!
//! _To run this example, you must first install [Rust](https://www.rust-lang.org/tools/install) and [Docker](https://www.docker.com/get-started/)._
//!
//! ## Install `commonware-deployer`
//!
//! ```bash
//! cargo install commonware-deployer
//! ```
//!
//! ## Create Deployer Artifacts
//!
//! ```bash
//! cargo run --bin setup -- --peers 3 --bootstrappers 1 --regions us-west-2,us-east-1,eu-west-1 --instance-type c7g.xlarge --storage-size 10 --storage-class gp3 --worker-threads 4 --message-size 1024 --message-backlog 16384 --mailbox-size 16384 --dashboard dashboard.json --output assets
//! ```
//!
//! _We use 3 peers (instead of the 2 required to test connection performance) to demonstrate that peer discovery works._
//!
//! ## Build Flood Binary
//!
//! ### Build Cross-Platform Compiler
//!
//! ```bash
//! docker build -t flood-builder .
//! ```
//!
//! ### Compile Binary for ARM64
//!
//! ```bash
//! docker run -it -v ${PWD}/../..:/monorepo flood-builder
//! ```
//!
//! _Emitted binary `flood` is placed in `assets`._
//!
//! ## Deploy Flood Binary
//!
//! ```bash
//! cd assets
//! deployer aws create --config config.yaml
//! ```
//!
//! # Monitor Performance on Grafana
//!
//! Visit `http://<monitoring-ip>:3000/d/flood`
//!
//! _This dashboard is only accessible from the IP used to deploy the infrastructure._
//!
//! ## (Optional) Update Flood Binary
//!
//! ## Re-Compile Binary for ARM64
//!
//! ```bash
//! docker run -it -v ${PWD}/../..:/monorepo flood-builder
//! ```
//!
//! ## Restart Flood Binary on EC2 Instances
//!
//! ```bash
//! deployer aws update --config config.yaml
//! ```
//!
//! # Destroy Infrastructure
//!
//! ```bash
//! deployer aws destroy --config config.yaml
//! ```
//!
//! # Debugging
//!
//! ## Missing AWS Credentials
//!
//! If `commonware-deployer` can't detect your AWS credentials, you'll see a "Request has expired." error:
//!
//! ```txt
//! 2025-03-05T01:36:47.550105Z INFO deployer::ec2::create: created EC2 client region="eu-west-1"
//! 2025-03-05T01:36:48.268330Z ERROR deployer: failed to create EC2 deployment error=AwsEc2(Unhandled(Unhandled { source: ErrorMetadata { code: Some("RequestExpired"), message: Some("Request has expired."), extras: Some({"aws_request_id": "006f6b92-4965-470d-8eac-7c9644744bdf"}) }, meta: ErrorMetadata { code: Some("RequestExpired"), message: Some("Request has expired."), extras: Some({"aws_request_id": "006f6b92-4965-470d-8eac-7c9644744bdf"}) } }))
//! ```
//!
//! ## EC2 Throttling
//!
//! EC2 instances may throttle network traffic if a workload exceeds the allocation for a particular instance type. To check
//! if an instance is throttled, SSH into the instance and run:
//!
//! ```bash
//! ethtool -S ens5 | grep "allowance"
//! ```
//!
//! If throttled, you'll see a non-zero value for some "allowance" item:
//!
//! ```txt
//! bw_in_allowance_exceeded: 0
//! bw_out_allowance_exceeded: 14368
//! pps_allowance_exceeded: 0
//! conntrack_allowance_exceeded: 0
//! linklocal_allowance_exceeded: 0
//! ```
use ;
/// Configuration for flood.