You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: apps/fortuna/README.md
+54Lines changed: 54 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -40,6 +40,60 @@ Please add the changed files in the `.sqlx` folder to your git commit.
40
40
The Fortuna binary has a command-line interface to perform useful operations on the contract, such as
41
41
registering a new randomness provider, or drawing a random value. To see the available commands, simply run `cargo run`.
42
42
43
+
## Multiple Replica Setup
44
+
45
+
Fortuna supports running multiple replica instances for high availability and reliability. This prevents service interruption if one instance goes down and distributes the workload across multiple instances.
46
+
47
+
### How Replica Assignment Works
48
+
49
+
- Each replica is assigned a unique `replica_id` (0, 1, 2, etc.)
50
+
- Requests are distributed using modulo assignment: `sequence_number % total_replicas`
51
+
- Each replica primarily handles requests assigned to its ID
52
+
- After a configurable delay, replicas will process requests from other replicas as backup (failover)
1. **Separate Wallets**: Each replica MUST use a different private key to avoid nonce conflicts
86
+
2. **Backup Delay**: Set `backup_delay_seconds` long enough to allow primary replica to process requests, but short enough for acceptable failover time (recommended: 30-60 seconds)
87
+
3. **Monitoring**: Monitor each replica's processing metrics to ensure proper load distribution
88
+
4. **Gas Management**: Each replica needs sufficient ETH balance for gas fees
89
+
90
+
### Failover Behavior
91
+
92
+
- Primary replica processes requests immediately
93
+
- Backup replicas wait for `backup_delay_seconds` before checking if request is still unfulfilled
94
+
- If request is already fulfilled during the delay, backup replica skips processing
95
+
- This prevents duplicate transactions and wasted gas while ensuring reliability
96
+
43
97
## Local Development
44
98
45
99
To start an instance of the webserver for local testing, you first need to perform a few setup steps:
0 commit comments