|
| 1 | +# Benchmarking |
| 2 | + |
| 3 | +We have two types of benchmarking: |
| 4 | + |
| 5 | +- E2E benchmarking running the service (HTTP or UDP tracker). |
| 6 | +- Internal torrents repository benchmarking. |
| 7 | + |
| 8 | +## E2E benchmarking |
| 9 | + |
| 10 | +We are using the scripts provided by [aquatic](https://github.com/greatest-ape/aquatic). |
| 11 | + |
| 12 | +Installing both commands: |
| 13 | + |
| 14 | +```console |
| 15 | +cargo install aquatic_udp_load_test |
| 16 | +cargo install aquatic_http_load_test |
| 17 | +``` |
| 18 | + |
| 19 | +### Run UDP load test |
| 20 | + |
| 21 | +Run the tracker with UDP service enabled on port 3000 and set log level to `error`. |
| 22 | + |
| 23 | +```toml |
| 24 | +log_level = "error" |
| 25 | + |
| 26 | +[[udp_trackers]] |
| 27 | +bind_address = "0.0.0.0:3000" |
| 28 | +enabled = true |
| 29 | +``` |
| 30 | + |
| 31 | +Run the load test with: |
| 32 | + |
| 33 | +```console |
| 34 | +aquatic_udp_load_test |
| 35 | +``` |
| 36 | + |
| 37 | +Output: |
| 38 | + |
| 39 | +```output |
| 40 | +Starting client with config: Config { |
| 41 | + server_address: 127.0.0.1:3000, |
| 42 | + log_level: Error, |
| 43 | + workers: 1, |
| 44 | + duration: 0, |
| 45 | + network: NetworkConfig { |
| 46 | + multiple_client_ipv4s: true, |
| 47 | + first_port: 45000, |
| 48 | + poll_timeout: 276, |
| 49 | + poll_event_capacity: 2877, |
| 50 | + recv_buffer: 6000000, |
| 51 | + }, |
| 52 | + requests: RequestConfig { |
| 53 | + number_of_torrents: 10000, |
| 54 | + scrape_max_torrents: 50, |
| 55 | + weight_connect: 0, |
| 56 | + weight_announce: 100, |
| 57 | + weight_scrape: 1, |
| 58 | + torrent_gamma_shape: 0.2, |
| 59 | + torrent_gamma_scale: 100.0, |
| 60 | + peer_seeder_probability: 0.25, |
| 61 | + additional_request_probability: 0.5, |
| 62 | + }, |
| 63 | +} |
| 64 | +
|
| 65 | +Requests out: 32632.43/second |
| 66 | +Responses in: 24239.33/second |
| 67 | + - Connect responses: 7896.91 |
| 68 | + - Announce responses: 16327.01 |
| 69 | + - Scrape responses: 15.40 |
| 70 | + - Error responses: 0.00 |
| 71 | +Peers per announce response: 33.10 |
| 72 | +``` |
| 73 | + |
| 74 | +### Run HTTP load test |
| 75 | + |
| 76 | +Run the tracker with UDP service enabled on port 3000 and set log level to `error`. |
| 77 | + |
| 78 | +```toml |
| 79 | +[[udp_trackers]] |
| 80 | +bind_address = "0.0.0.0:3000" |
| 81 | +enabled = true |
| 82 | +``` |
| 83 | + |
| 84 | +Run the load test with: |
| 85 | + |
| 86 | +```console |
| 87 | +aquatic_http_load_test |
| 88 | +``` |
| 89 | + |
| 90 | +Output: |
| 91 | + |
| 92 | +```output |
| 93 | +Starting client with config: Config { |
| 94 | + server_address: 127.0.0.1:3000, |
| 95 | + log_level: Error, |
| 96 | + num_workers: 1, |
| 97 | + num_connections: 128, |
| 98 | + connection_creation_interval_ms: 10, |
| 99 | + url_suffix: "", |
| 100 | + duration: 0, |
| 101 | + keep_alive: true, |
| 102 | + torrents: TorrentConfig { |
| 103 | + number_of_torrents: 10000, |
| 104 | + peer_seeder_probability: 0.25, |
| 105 | + weight_announce: 5, |
| 106 | + weight_scrape: 0, |
| 107 | + torrent_gamma_shape: 0.2, |
| 108 | + torrent_gamma_scale: 100.0, |
| 109 | + }, |
| 110 | + cpu_pinning: CpuPinningConfigDesc { |
| 111 | + active: false, |
| 112 | + direction: Descending, |
| 113 | + hyperthread: System, |
| 114 | + core_offset: 0, |
| 115 | + }, |
| 116 | +} |
| 117 | +``` |
| 118 | + |
| 119 | +### Comparing UDP tracker with other Rust implementations |
| 120 | + |
| 121 | +#### Torrust UDP Tracker |
| 122 | + |
| 123 | +Running the tracker: |
| 124 | + |
| 125 | +```console |
| 126 | +git@github.com:torrust/torrust-tracker.git |
| 127 | +cd torrust-tracker |
| 128 | +cargo build --release |
| 129 | +TORRUST_TRACKER_PATH_CONFIG="./share/default/config/tracker.udp.benchmarking.toml" ./target/release/torrust-tracker |
| 130 | +``` |
| 131 | + |
| 132 | +Running the test: `aquatic_udp_load_test`. |
| 133 | + |
| 134 | +```output |
| 135 | +Requests out: 13075.56/second |
| 136 | +Responses in: 12058.38/second |
| 137 | + - Connect responses: 1017.18 |
| 138 | + - Announce responses: 11035.00 |
| 139 | + - Scrape responses: 6.20 |
| 140 | + - Error responses: 0.00 |
| 141 | +Peers per announce response: 41.13 |
| 142 | +``` |
| 143 | + |
| 144 | +#### Aquatic UDP Tracker |
| 145 | + |
| 146 | +Running the tracker: |
| 147 | + |
| 148 | +```console |
| 149 | +git clone git@github.com:greatest-ape/aquatic.git |
| 150 | +cd aquatic |
| 151 | +cargo build --release -p aquatic_udp |
| 152 | +./target/release/aquatic_udp -c "aquatic-udp-config.toml" |
| 153 | +./target/release/aquatic_udp -c "aquatic-udp-config.toml" |
| 154 | +``` |
| 155 | + |
| 156 | +Running the test: `aquatic_udp_load_test`. |
| 157 | + |
| 158 | +```output |
| 159 | +Requests out: 383873.14/second |
| 160 | +Responses in: 383440.35/second |
| 161 | + - Connect responses: 429.19 |
| 162 | + - Announce responses: 379249.22 |
| 163 | + - Scrape responses: 3761.93 |
| 164 | + - Error responses: 0.00 |
| 165 | +Peers per announce response: 15.33 |
| 166 | +``` |
| 167 | + |
| 168 | +#### Torrust-Actix UDP Tracker |
| 169 | + |
| 170 | +Run the tracker with UDP service enabled on port 3000 and set log level to `error`. |
| 171 | + |
| 172 | +```toml |
| 173 | +[[udp_trackers]] |
| 174 | +bind_address = "0.0.0.0:3000" |
| 175 | +enabled = true |
| 176 | +``` |
| 177 | + |
| 178 | +```console |
| 179 | +git clone https://github.com/Power2All/torrust-actix.git |
| 180 | +cd torrust-actix |
| 181 | +cargo build --release |
| 182 | +./target/release/torrust-actix --create-config |
| 183 | +./target/release/torrust-actix |
| 184 | +``` |
| 185 | + |
| 186 | +Running the test: `aquatic_udp_load_test`. |
| 187 | + |
| 188 | +```output |
| 189 | +Requests out: 3072.94/second |
| 190 | +Responses in: 2395.15/second |
| 191 | + - Connect responses: 556.79 |
| 192 | + - Announce responses: 1821.16 |
| 193 | + - Scrape responses: 17.20 |
| 194 | + - Error responses: 0.00 |
| 195 | +Peers per announce response: 133.88 |
| 196 | +``` |
| 197 | + |
| 198 | +### Results |
| 199 | + |
| 200 | +Announce request per second: |
| 201 | + |
| 202 | +| Tracker | Announce | |
| 203 | +|---------------|-----------| |
| 204 | +| Aquatic | 379,249 | |
| 205 | +| Torrust | 11,035 | |
| 206 | +| Torrust-Actix | 1,821 | |
| 207 | + |
| 208 | +## Repository benchmarking |
| 209 | + |
| 210 | +You can run it with: |
| 211 | + |
| 212 | +```console |
| 213 | +cargo run --release -p torrust-torrent-repository-benchmarks -- --threads 4 --sleep 0 --compare true |
| 214 | +``` |
| 215 | + |
| 216 | +It tests the different implementation for the internal torrent storage. |
| 217 | + |
| 218 | +```output |
| 219 | +tokio::sync::RwLock<std::collections::BTreeMap<InfoHash, Entry>> |
| 220 | +add_one_torrent: Avg/AdjAvg: (60ns, 59ns) |
| 221 | +update_one_torrent_in_parallel: Avg/AdjAvg: (10.909457ms, 0ns) |
| 222 | +add_multiple_torrents_in_parallel: Avg/AdjAvg: (13.88879ms, 0ns) |
| 223 | +update_multiple_torrents_in_parallel: Avg/AdjAvg: (7.772484ms, 7.782535ms) |
| 224 | +
|
| 225 | +std::sync::RwLock<std::collections::BTreeMap<InfoHash, Entry>> |
| 226 | +add_one_torrent: Avg/AdjAvg: (43ns, 39ns) |
| 227 | +update_one_torrent_in_parallel: Avg/AdjAvg: (4.020937ms, 4.020937ms) |
| 228 | +add_multiple_torrents_in_parallel: Avg/AdjAvg: (5.896177ms, 5.768448ms) |
| 229 | +update_multiple_torrents_in_parallel: Avg/AdjAvg: (3.883823ms, 3.883823ms) |
| 230 | +
|
| 231 | +std::sync::RwLock<std::collections::BTreeMap<InfoHash, Arc<std::sync::Mutex<Entry>>>> |
| 232 | +add_one_torrent: Avg/AdjAvg: (51ns, 49ns) |
| 233 | +update_one_torrent_in_parallel: Avg/AdjAvg: (3.252314ms, 3.149109ms) |
| 234 | +add_multiple_torrents_in_parallel: Avg/AdjAvg: (8.411094ms, 8.411094ms) |
| 235 | +update_multiple_torrents_in_parallel: Avg/AdjAvg: (4.106086ms, 4.106086ms) |
| 236 | +
|
| 237 | +tokio::sync::RwLock<std::collections::BTreeMap<InfoHash, Arc<std::sync::Mutex<Entry>>>> |
| 238 | +add_one_torrent: Avg/AdjAvg: (91ns, 90ns) |
| 239 | +update_one_torrent_in_parallel: Avg/AdjAvg: (3.542378ms, 3.435695ms) |
| 240 | +add_multiple_torrents_in_parallel: Avg/AdjAvg: (15.651172ms, 15.651172ms) |
| 241 | +update_multiple_torrents_in_parallel: Avg/AdjAvg: (4.368189ms, 4.257572ms) |
| 242 | +
|
| 243 | +tokio::sync::RwLock<std::collections::BTreeMap<InfoHash, Arc<tokio::sync::Mutex<Entry>>>> |
| 244 | +add_one_torrent: Avg/AdjAvg: (111ns, 109ns) |
| 245 | +update_one_torrent_in_parallel: Avg/AdjAvg: (6.590677ms, 6.808535ms) |
| 246 | +add_multiple_torrents_in_parallel: Avg/AdjAvg: (16.572217ms, 16.30488ms) |
| 247 | +update_multiple_torrents_in_parallel: Avg/AdjAvg: (4.073221ms, 4.000122ms) |
| 248 | +``` |
| 249 | + |
| 250 | +## Other considerations |
| 251 | + |
| 252 | +We are testing new repository implementations that allow concurrent writes. See <https://github.com/torrust/torrust-tracker/issues/565>. |
0 commit comments