|
| 1 | +# Compute (CPU) cost estimation per node |
| 2 | + |
| 3 | +> [!Note] |
| 4 | +> This analysis assumes fully utilized block space for conservative |
| 5 | +> upper bound estimation. |
| 6 | +
|
| 7 | +All CPU time values in this document are derived from the simulation |
| 8 | +configuration file (`data/simulation/config.default.yaml`), which contains |
| 9 | +benchmark measurements for protocol operations. |
| 10 | + |
| 11 | +## Ouroboros Praos |
| 12 | + |
| 13 | +We start with Ouroboros Praos to establish a baseline. In Praos, CPU utilization |
| 14 | +comes from block validation: |
| 15 | + |
| 16 | +| Component | Validation Time | Source | |
| 17 | +| ------------------------------ | --------------- | ----------------------------------- | |
| 18 | +| Block header validation | 1ms | Same as IB header validation | |
| 19 | +| Block body validation constant | 50ms | Same as IB body validation constant | |
| 20 | +| Block body validation per byte | 0.0005ms | Same as IB body validation per byte | |
| 21 | + |
| 22 | +### Block Rate Calculation |
| 23 | + |
| 24 | +| Parameter | Value | Formula | |
| 25 | +| ----------------------- | -------- | ------------------ | |
| 26 | +| Slot length | 1 second | Protocol parameter | |
| 27 | +| Active slot coefficient | 0.05 | Protocol parameter | |
| 28 | +| **Blocks per second** | **0.05** | $$1 \times 0.05$$ | |
| 29 | + |
| 30 | +### CPU Utilization Formula |
| 31 | + |
| 32 | +$$C_{\text{praos}} = N_{\text{blocks}} \times (H_{\text{validation}} + B_{\text{validation}})$$ |
| 33 | + |
| 34 | +where: |
| 35 | + |
| 36 | +- $N_{\text{blocks}}$ = Blocks per second |
| 37 | +- $H_{\text{validation}}$ = Header validation time in ms |
| 38 | +- $B_{\text{validation}}$ = Body validation time in ms (constant + per-byte component) |
| 39 | + |
| 40 | +### Praos CPU Calculation (0.05 blocks/s) |
| 41 | + |
| 42 | +$$C_{\text{praos}} = 0.05 \times (1 + (50 + 90,112 \times 0.0005))$$ |
| 43 | + |
| 44 | +$$C_{\text{praos}} = 0.05 \times (1 + 95.06)$$ |
| 45 | + |
| 46 | +$$C_{\text{praos}} = 0.05 \times 96.06 \approx 4.8\text{ ms/s}$$ |
| 47 | + |
| 48 | +Thus, Praos at 0.05 blocks/s consumes approximately 4.8ms of CPU time per |
| 49 | +second, which is about 0.48% of a single CPU core. |
| 50 | + |
| 51 | +## Ouroboros Leios |
| 52 | + |
| 53 | +In Leios, CPU utilization is distributed across multiple components: Input |
| 54 | +Blocks (IBs), Endorsement Blocks (EBs), Votes, and Certificates in Ranking |
| 55 | +Blocks (RBs). |
| 56 | + |
| 57 | +### Component Processing Times |
| 58 | + |
| 59 | +| Component | Size / Unit | Validation Time | Config Reference | |
| 60 | +| ----------- | ---------------- | -------------------- | -------------------------------------- | |
| 61 | +| IB Header | 304 bytes | 1ms | `ib-head-validation-cpu-time-ms` | |
| 62 | +| IB Body | 98,304 bytes | 50ms + 0.0005ms/byte | `ib-body-validation-cpu-time-ms-*` | |
| 63 | +| EB | 240 bytes + refs | 1ms | `eb-validation-cpu-time-ms` | |
| 64 | +| Vote | ~150 bytes | 0.816ms | `vote-validation-cpu-time-ms` | |
| 65 | +| Certificate | 7,168 bytes | 140ms | `cert-validation-cpu-time-ms-constant` | |
| 66 | + |
| 67 | +### Base Parameters |
| 68 | + |
| 69 | +| Parameter | Value | Source | |
| 70 | +| --------------- | -------------- | ----------------------------- | |
| 71 | +| Stage length | 20 slots (20s) | `leios-stage-length-slots` | |
| 72 | +| EBs per stage | 1.5 | `eb-generation-probability` | |
| 73 | +| Votes per EB | 600 | `vote-generation-probability` | |
| 74 | +| Votes per stage | 900 | 600 votes/EB × 1.5 EBs/stage | |
| 75 | + |
| 76 | +### Base CPU Usage Formulas |
| 77 | + |
| 78 | +1. **IB Processing CPU**: |
| 79 | + |
| 80 | + $$C_{\text{ib}} = N_{\text{ib}} \times (H_{\text{ib}} + B_{\text{ib}})$$ |
| 81 | + where: |
| 82 | + - $N_{\text{ib}}$ = Number of IBs per second |
| 83 | + - $H_{\text{ib}}$ = IB header validation time (1ms) |
| 84 | + - $B_{\text{ib}}$ = IB body validation time (50ms + 98,304×0.0005ms = 99.15ms) |
| 85 | + |
| 86 | +2. **EB Processing CPU**: |
| 87 | + |
| 88 | + $$C_{\text{eb}} = \frac{N_{\text{eb}} \times T_{\text{eb}}}{S_{\text{length}}}$$ |
| 89 | + where: |
| 90 | + - $N_{\text{eb}}$ = Number of EBs per stage (1.5) |
| 91 | + - $T_{\text{eb}}$ = EB validation time (1ms) |
| 92 | + - $S_{\text{length}}$ = Stage length in seconds (20s) |
| 93 | + |
| 94 | +3. **Vote Processing CPU**: |
| 95 | + |
| 96 | + $$C_{\text{vote}} = \frac{N_{\text{votes}} \times T_{\text{vote}}}{S_{\text{length}}}$$ |
| 97 | + where: |
| 98 | + - $N_{\text{votes}}$ = Number of votes per stage (900) |
| 99 | + - $T_{\text{vote}}$ = Vote validation time (0.816ms) |
| 100 | + - $S_{\text{length}}$ = Stage length in seconds (20s) |
| 101 | + |
| 102 | +4. **Certificate Processing CPU**: |
| 103 | + |
| 104 | + $$C_{\text{cert}} = \frac{N_{\text{cert}} \times T_{\text{cert}}}{S_{\text{length}}}$$ |
| 105 | + where: |
| 106 | + - $N_{\text{cert}}$ = Number of certificates per stage (1) |
| 107 | + - $T_{\text{cert}}$ = Certificate validation time (140ms) |
| 108 | + - $S_{\text{length}}$ = Stage length in seconds (20s) |
| 109 | + |
| 110 | +5. **Total CPU Usage**: |
| 111 | + |
| 112 | + $$C_{\text{total}} = C_{\text{ib}} + C_{\text{eb}} + C_{\text{vote}} + C_{\text{cert}}$$ |
| 113 | + |
| 114 | +### CPU Time Calculation at 0.05 IB/s (equivalent to Praos rate) |
| 115 | + |
| 116 | +1. **IB Processing**: |
| 117 | + |
| 118 | + $$C_{\text{ib}} = 0.05 \times (1 + 99.15) = 5.01\text{ ms/s}$$ |
| 119 | + |
| 120 | +2. **EB Processing**: |
| 121 | + |
| 122 | + $$C_{\text{eb}} = \frac{1.5 \times 1}{20} = 0.075\text{ ms/s}$$ |
| 123 | + |
| 124 | +3. **Vote Processing**: |
| 125 | + |
| 126 | + $$C_{\text{vote}} = \frac{900 \times 0.816}{20} = 36.72\text{ ms/s}$$ |
| 127 | + |
| 128 | +4. **Certificate Processing**: |
| 129 | + |
| 130 | + $$C_{\text{cert}} = \frac{1 \times 140}{20} = 7.0\text{ ms/s}$$ |
| 131 | + |
| 132 | +5. **Total CPU Usage**: |
| 133 | + |
| 134 | + $$C_{\text{total}} = 5.01 + 0.075 + 36.72 + 7.0 = 48.81\text{ ms/s}$$ |
| 135 | + |
| 136 | +Thus, at 0.05 IB/s, Leios consumes approximately 48.8ms of CPU time per second, |
| 137 | +which is about 4.9% of a single CPU core. |
| 138 | + |
| 139 | +### CPU Utilization at Different IB Rates |
| 140 | + |
| 141 | +| IB/s | IB Processing | EB Processing | Vote Processing | Certificate Processing | Total CPU Time/s | % of One Core | Min Cores Needed | Recommended Cores | |
| 142 | +| ---- | ------------- | ------------- | --------------- | ---------------------- | ---------------- | ------------- | ---------------- | ----------------- | |
| 143 | +| 0.05 | 5.01ms | 0.075ms | 36.72ms | 7.0ms | 48.81ms | 4.9% | 1 | 1 | |
| 144 | +| 1 | 100.15ms | 0.075ms | 36.72ms | 7.0ms | 143.95ms | 14.4% | 1 | 2 | |
| 145 | +| 5 | 500.75ms | 0.075ms | 36.72ms | 7.0ms | 544.55ms | 54.5% | 1 | 2 | |
| 146 | +| 10 | 1,001.5ms | 0.075ms | 36.72ms | 7.0ms | 1,045.30ms | 104.5% | 2 | 4 | |
| 147 | +| 20 | 2,003ms | 0.075ms | 36.72ms | 7.0ms | 2,046.80ms | 204.7% | 3 | 6 | |
| 148 | +| 30 | 3,004.5ms | 0.075ms | 36.72ms | 7.0ms | 3,048.30ms | 304.8% | 4 | 8 | |
| 149 | + |
| 150 | +> [!Note] |
| 151 | +> |
| 152 | +> - "Min Cores Needed" is calculated by dividing total CPU time by 1000ms and |
| 153 | +> rounding up |
| 154 | +> - "Recommended Cores" adds redundancy for spikes and other node operations |
| 155 | +> - This assumes even distribution of work and perfect parallelization, which is |
| 156 | +> optimistic. |
| 157 | +
|
| 158 | +### CPU Component Analysis (at 0.05 IB/s) |
| 159 | + |
| 160 | +| Component | CPU Time | % of Total | |
| 161 | +| ---------------------- | -------- | ---------- | |
| 162 | +| IB Processing | 5.01ms | 10.3% | |
| 163 | +| EB Processing | 0.075ms | 0.2% | |
| 164 | +| Vote Processing | 36.72ms | 75.2% | |
| 165 | +| Certificate Processing | 7.0ms | 14.3% | |
| 166 | + |
| 167 | +This shows that at the Praos-equivalent rate of 0.05 IB/s, vote processing |
| 168 | +dominates CPU usage (75.2%), followed by certificate processing (14.3%) and IB |
| 169 | +processing (10.3%). |
| 170 | + |
| 171 | +> [!Note] |
| 172 | +> This analysis does not yet include estimates for: |
| 173 | +> - Transaction and mempool operations |
| 174 | +> - Ledger computation and state reconciliation |
| 175 | +> |
| 176 | +> These components will contribute additional CPU overhead in a complete implementation. |
| 177 | +
|
| 178 | +### Comparative Efficiency (Leios vs. Praos) |
| 179 | + |
| 180 | +| IB/s | Leios CPU Time | Praos Equivalent CPU Time | Ratio (Leios:Praos) | |
| 181 | +| ---- | -------------- | ------------------------- | ------------------- | |
| 182 | +| 0.05 | 48.8ms | 4.8ms | 10.17:1 | |
| 183 | +| 1 | 144.0ms | 96.1ms | 1.50:1 | |
| 184 | +| 5 | 544.6ms | 480.3ms | 1.13:1 | |
| 185 | +| 10 | 1,045.3ms | 960.6ms | 1.09:1 | |
| 186 | + |
| 187 | +At 0.05 IB/s, Leios requires significantly more CPU than Praos, primarily due to |
| 188 | +vote processing and certificate overhead. At higher throughput rates, the |
| 189 | +relative overhead of votes and certificates diminishes, making Leios approach |
| 190 | +the per-transaction efficiency of Praos. |
| 191 | + |
| 192 | +## Monthly Cost by Cloud Provider ($) |
| 193 | + |
| 194 | +Using standard compute-optimized instances: |
| 195 | + |
| 196 | +| Provider | 2 Core | 4 Core | 8 Core | Notes | |
| 197 | +| ---------- | ------ | ------- | ------- | ---------------------- | |
| 198 | +| AWS c6i | $62.05 | $124.10 | $248.20 | On-demand, US East | |
| 199 | +| GCP c2/n2 | $52.34 | $152.35 | $304.78 | On-demand, US Central1 | |
| 200 | +| Azure Fsv2 | $61.76 | $123.37 | $246.74 | On-demand, East US | |
| 201 | +| DO CPU-Opt | $42.00 | $84.00 | $168.00 | Regular pricing | |
| 202 | +| Linode | $36.00 | $60.00 | $120.00 | Standard pricing | |
| 203 | +| Hetzner | $5.40 | $17.80 | $32.90 | Standard pricing | |
| 204 | + |
| 205 | +> [!Note] |
| 206 | +> |
| 207 | +> - Prices are for US regions and may vary by location |
| 208 | +> - Assumes dedicated compute-optimized instances |
| 209 | +> - Does not include potential savings from reserved instances or spot pricing |
| 210 | +
|
| 211 | +## Recommendations |
| 212 | + |
| 213 | +1. For 0.05-1 IB/s: 2 cores should be sufficient ($5-$62/month) |
| 214 | +2. For 1-10 IB/s: 4 cores recommended ($18-$152/month) |
| 215 | +3. For 10-30 IB/s: 8 cores recommended ($33-$305/month) |
| 216 | +4. Above 30 IB/s: Consider multiple nodes or higher-end instances |
| 217 | + |
| 218 | +> [!Important] |
| 219 | +> |
| 220 | +> Key considerations: |
| 221 | +> Real-world performance may require more cores due to: |
| 222 | +> |
| 223 | +> - Network stack overhead |
| 224 | +> - OS operations |
| 225 | +> - Uneven workload distribution |
| 226 | +> - Memory bandwidth limitations |
| 227 | +> - Other node operations not included in calculation |
| 228 | +
|
| 229 | +## Compute Cost Sources |
| 230 | + |
| 231 | +| Provider | Instance Type | Source | Last Updated | |
| 232 | +| ------------ | ------------- | -------------------------------------------------------------------- | ------------ | |
| 233 | +| AWS | c6i | https://aws.amazon.com/ec2/pricing/on-demand/ | Apr 2025 | |
| 234 | +| GCP | c2/n2 | https://cloud.google.com/compute/vm-instance-pricing | Apr 2025 | |
| 235 | +| Azure | Fsv2 | https://azure.microsoft.com/pricing/details/virtual-machines/series/ | Apr 2025 | |
| 236 | +| DigitalOcean | CPU-Optimized | https://www.digitalocean.com/pricing/compute | Apr 2025 | |
| 237 | +| Linode | Dedicated CPU | https://www.linode.com/pricing/ | Apr 2025 | |
| 238 | +| Hetzner | CPX | https://www.hetzner.com/cloud/pricing | Apr 2025 | |
| 239 | + |
| 240 | +Note: Prices shown are for US regions and may vary by location. Many providers |
| 241 | +offer significant discounts for reserved instances or longer-term commitments. |
| 242 | +The table shows standard on-demand rates for compute-optimized instances. |
0 commit comments