vac.dev-experimental-old/waku-v1-v2-bandwidth-compar...

498 lines
30 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html class="h-full" lang="en-US">
<head>
<title>Vac - Waku v1 vs Waku v2: Bandwidth Comparison</title>
<meta charset="utf-8" />
<meta http-equiv="x-ua-compatible" content="ie=edge" />
<title>Vac</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<script async defer src="https://cdn.simpleanalytics.io/hello.js"></script>
<noscript><img src="https://api.simpleanalytics.io/hello.gif" alt="" /></noscript>
<!-- Fathom - simple website analytics - https://github.com/usefathom/fathom -->
<script>
(function (f, a, t, h, o, m) {
a[h] =
a[h] ||
function () {
(a[h].q = a[h].q || []).push(arguments);
};
(o = f.createElement("script")), (m = f.getElementsByTagName("script")[0]);
o.async = 1;
o.src = t;
o.id = "fathom-script";
m.parentNode.insertBefore(o, m);
})(document, window, "//fathom.status.im/tracker.js", "fathom");
fathom("set", "siteId", "YELIA");
fathom("trackPageview");
</script>
<!-- / Fathom -->
<!-- Twitter cards -->
<meta name="twitter:site" content="@vacp2p" />
<meta name="twitter:creator" content="@hanno" />
<meta name="twitter:title" content="Waku v1 vs Waku v2: Bandwidth Comparison" />
<meta name="twitter:description" content="A local comparison of bandwidth profiles showing significantly improved scalability in Waku v2 over Waku v1." />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="https://vac.dev/assets/img/waku1-vs-waku2/waku1-vs-waku2-overall-network-size.png" />
<!-- end of Twitter cards -->
<link rel="shortcut icon" href="/assets/img/favicon.png" type="image/png" />
<link rel="preload" href="/fonts/OpenSans-Regular.woff2" as="font" type="font/woff2" crossorigin />
<link rel="preload" href="/fonts/OpenSans-SemiBold.woff2" as="font" type="font/woff2" crossorigin />
<link rel="preload" href="/fonts/OpenSans-SemiBoldItalic.woff2" as="font" type="font/woff2" crossorigin />
<link rel="stylesheet" href="/assets/css/style.css" />
</head>
<body class="h-full flex flex-col font-body">
<div class="flex-grow container max-w-screen-xl mx-auto px-5 md:px-12 lg:pt-6">
<header class="sm:sticky sm:top-0 bg-white z-50">
<div class="container max-w-screen-xl sm:border-b">
<div class="nav-section flex justify-between items-center py-3 md:py-5 lg:py-10">
<div class="logo md:pr-8 l:p-0">
<a href="/"><img src="/assets/img/logo.png" alt="Vac logo" class="w-9 h-11" /></a>
</div>
<div class="flex justify-between items-center w-9/12">
<div class="burger block sm:hidden z-50">
<button class="burger__button burger__button--open fixed top-2 right-5 w-12 h-12" type="button" aria-label="Mobile menu button">
<img class="burger__icon" src="/assets/img/burger.svg" alt="Open menu button" />
</button>
<button class="burger__button burger__button--close hidden fixed top-2 right-5 w-12 h-12" type="button" aria-label="Close mobile menu button">
<img class="burger__icon burger__icon--close" src="/assets/img/close.svg" alt="Close menu button" />
</button>
</div>
<nav class="nav max-w-screen-xm md:max-w-screen-sl container">
<ul class="nav__list hidden sm:flex justify-between container text-xs font-semibold md:pr-8 l:p-0">
<li class="hover:opacity-50">
<a class="nav__link" href="/#work">Work</a>
</li>
<li class="hover:opacity-50">
<a class="nav__link" href="/#about">About</a>
</li>
<li class="hover:opacity-50">
<a class="nav__link" href="/#join">Join Vac</a>
</li>
<li class="hover:opacity-50">
<a class="nav__link" href="/research-log">Research log</a>
</li>
<li class="hover:opacity-50">
<a class="nav__link" href="/media">Media</a>
</li>
<li class="hover:opacity-50">
<a href="https://rfc.vac.dev/" target="_blank" rel="noopener noreferrer">Specs</a>
</li>
<li class="hover:opacity-50">
<a href="https://forum.vac.dev/" target="_blank" rel="noopener noreferrer">Forum</a>
</li>
</ul>
</nav>
<ul class="social items-center hidden md:flex">
<li class="pr-5">
<a href="https://twitter.com/vacp2p" target="_blank" rel="noopener noreferrer">
<svg width="25" height="21" viewBox="0 0 25 21" fill="none" xmlns="http://www.w3.org/2000/svg" class="hover:opacity-50">
<path
d="M24.8872 3.04499C23.9872 3.43499 23.0572 3.70498 22.0672 3.82499C23.0872 3.22498 23.8672 2.26499 24.2272 1.09499C23.2672 1.66499 22.2172 2.05499 21.1072 2.29499C20.2072 1.33499 18.9172 0.734985 17.5072 0.734985C14.7772 0.734985 12.5872 2.95499 12.5872 5.65499C12.5872 6.04499 12.6172 6.40498 12.7072 6.76498C8.62721 6.58498 5.02721 4.60498 2.59721 1.63499C0.857207 4.75498 2.80721 7.33499 4.09721 8.20499C3.31721 8.20499 2.53721 7.96499 1.87721 7.60499C1.87721 10.035 3.58721 12.045 5.80721 12.495C5.32721 12.645 4.24721 12.735 3.58721 12.585C4.21721 14.535 6.04721 15.975 8.17721 16.005C6.49721 17.325 4.03721 18.375 0.887207 18.045C3.07721 19.455 5.65721 20.265 8.44721 20.265C17.5072 20.265 22.4272 12.765 22.4272 6.28499C22.4272 6.07499 22.4272 5.86499 22.3972 5.65499C23.4172 4.90499 24.2572 4.03499 24.8872 3.04499Z"
fill="#151512"
/>
</svg>
</a>
</li>
<li class="pr-5">
<a href="https://github.com/vacp2p" target="_blank" rel="noopener noreferrer">
<svg width="26" height="25" viewBox="0 0 26 25" fill="none" xmlns="http://www.w3.org/2000/svg" class="hover:opacity-50">
<path
d="M12.8857 0.856567C6.26021 0.856567 0.915339 6.20154 0.950043 12.7951C0.9778 18.0687 4.43935 22.5427 9.21766 24.1227C9.81824 24.2327 10.0353 23.864 10.0336 23.5474C10.0321 23.2635 10.0177 22.5129 10.0065 21.5171C6.67274 22.238 5.95552 19.9163 5.95552 19.9163C5.40376 18.5369 4.61433 18.1698 4.61433 18.1698C3.51994 17.4296 4.69151 17.4444 4.69151 17.4444C5.89646 17.5291 6.53549 18.6751 6.53549 18.6751C7.61609 20.4989 9.35182 19.9727 10.0342 19.6665C10.1382 18.8951 10.4459 18.3689 10.7878 18.0702C8.12222 17.7684 5.31483 16.7443 5.29076 12.1708C5.2839 10.8672 5.74629 9.80152 6.50989 8.96619C6.3838 8.66445 5.96641 7.45009 6.61027 5.80766C6.61027 5.80766 7.61658 5.4866 9.9167 7.03094C10.8723 6.76636 11.8976 6.63408 12.9191 6.62962C13.9376 6.63556 14.9658 6.76636 15.9257 7.03242C18.2081 5.48809 19.2163 5.80914 19.2163 5.80914C19.8789 7.45306 19.4743 8.66594 19.3529 8.96767C20.1268 9.80301 20.5959 10.8687 20.6028 12.1723C20.6269 16.7577 17.8272 17.767 15.1558 18.0628C15.5882 18.4314 15.976 19.1597 15.9819 20.273C15.9903 21.8693 15.9821 23.1565 15.9841 23.5474C15.9858 23.867 16.2038 24.2386 16.8122 24.1212C21.5663 22.5397 24.9778 18.0672 24.95 12.7951C24.9153 6.20154 19.5142 0.856567 12.8857 0.856567Z"
fill="#151512"
/>
</svg>
</a>
</li>
<li>
<a href="https://discord.gg/PQFdubGt6d" target="_blank" rel="noopener noreferrer">
<svg width="25" height="21" viewBox="0 0 25 21" fill="none" xmlns="http://www.w3.org/2000/svg" class="hover:opacity-50">
<path
d="M22.7861 9.04256C21.8482 5.74455 20.7799 4.04048 20.7627 4.00991C20.7017 3.93459 19.189 2.104 15.5271 0.75L15.0353 2.0764C16.7774 2.72057 18.0116 3.50643 18.6899 4.01419C16.6599 3.40408 14.2431 3.03041 12.1008 3.03041C9.95851 3.03041 7.53775 3.40408 5.50128 4.01419C6.18496 3.50648 7.42744 2.72057 9.17631 2.0764L8.69846 0.75C5.02238 2.104 3.49044 3.93459 3.42863 4.00991C3.41108 4.04048 2.32479 5.74455 1.35221 9.04256C0.414855 12.2208 0.0415214 16.7045 0.027872 16.8843C0.109225 17.0131 1.97891 20.25 7.12077 20.25L8.43406 18.3536C6.97595 17.964 5.58693 17.3357 4.31689 16.4832L5.10228 15.3069C7.15122 16.6822 9.54509 17.4092 12.0251 17.4092C14.5051 17.4092 16.9067 16.6822 18.9701 15.3069L19.7431 16.4832C18.4641 17.3357 17.0684 17.964 15.6062 18.3536L16.8995 20.25C22.0414 20.25 23.9452 17.0131 24.0279 16.8843C24.0161 16.7045 23.69 12.2208 22.7861 9.04256ZM8.79853 12.7392H7.39228L7.40468 10.3841H8.81093L8.79853 12.7392ZM16.7071 12.7392H15.3008L15.3132 10.3841H16.7195L16.7071 12.7392Z"
fill="#151512"
/>
</svg>
</a>
</li>
</ul>
</div>
<div class="overlay container max-w-screen-sm w-full hidden sm:hidden fixed top-0 right-0 h-screen bg-black bg-opacity-40 z-30">
<nav class="nav-mobile hidden fixed top-0 right-0 flex flex-col justify-between items-center pt-14 px-12 pb-5 bg-white w-9/12 h-3/4 z-40">
<ul class="nav__list flex flex-col flex-1 justify-between items-center container box-content w-32 h-auto max-h-nav text-xs font-normal">
<li class="hover:opacity-50">
<a class="nav__link" href="/#work">Work</a>
</li>
<li class="hover:opacity-50">
<a class="nav__link" href="/#about">About</a>
</li>
<li class="hover:opacity-50">
<a class="nav__link" href="/#join">Join Vac</a>
</li>
<li class="hover:opacity-50">
<a class="nav__link" href="/research-log">Research log</a>
</li>
<li class="hover:opacity-50">
<a class="nav__link" href="/media">Media</a>
</li>
<li class="hover:opacity-50">
<a href="https://rfc.vac.dev/" target="_blank" rel="noopener noreferrer">Specs</a>
</li>
<li class="hover:opacity-50">
<a href="https://forum.vac.dev/" target="_blank" rel="noopener noreferrer">Forum</a>
</li>
</ul>
<ul class="social items-center flex mt-8">
<li class="pr-5">
<a href="https://twitter.com/vacp2p" target="_blank" rel="noopener noreferrer">
<svg width="25" height="21" viewBox="0 0 25 21" fill="none" xmlns="http://www.w3.org/2000/svg" class="hover:opacity-50">
<path
d="M24.8872 3.04499C23.9872 3.43499 23.0572 3.70498 22.0672 3.82499C23.0872 3.22498 23.8672 2.26499 24.2272 1.09499C23.2672 1.66499 22.2172 2.05499 21.1072 2.29499C20.2072 1.33499 18.9172 0.734985 17.5072 0.734985C14.7772 0.734985 12.5872 2.95499 12.5872 5.65499C12.5872 6.04499 12.6172 6.40498 12.7072 6.76498C8.62721 6.58498 5.02721 4.60498 2.59721 1.63499C0.857207 4.75498 2.80721 7.33499 4.09721 8.20499C3.31721 8.20499 2.53721 7.96499 1.87721 7.60499C1.87721 10.035 3.58721 12.045 5.80721 12.495C5.32721 12.645 4.24721 12.735 3.58721 12.585C4.21721 14.535 6.04721 15.975 8.17721 16.005C6.49721 17.325 4.03721 18.375 0.887207 18.045C3.07721 19.455 5.65721 20.265 8.44721 20.265C17.5072 20.265 22.4272 12.765 22.4272 6.28499C22.4272 6.07499 22.4272 5.86499 22.3972 5.65499C23.4172 4.90499 24.2572 4.03499 24.8872 3.04499Z"
fill="#151512"
/>
</svg>
</a>
</li>
<li class="pr-5">
<a href="https://github.com/vacp2p" target="_blank" rel="noopener noreferrer">
<svg width="26" height="25" viewBox="0 0 26 25" fill="none" xmlns="http://www.w3.org/2000/svg" class="hover:opacity-50">
<path
d="M12.8857 0.856567C6.26021 0.856567 0.915339 6.20154 0.950043 12.7951C0.9778 18.0687 4.43935 22.5427 9.21766 24.1227C9.81824 24.2327 10.0353 23.864 10.0336 23.5474C10.0321 23.2635 10.0177 22.5129 10.0065 21.5171C6.67274 22.238 5.95552 19.9163 5.95552 19.9163C5.40376 18.5369 4.61433 18.1698 4.61433 18.1698C3.51994 17.4296 4.69151 17.4444 4.69151 17.4444C5.89646 17.5291 6.53549 18.6751 6.53549 18.6751C7.61609 20.4989 9.35182 19.9727 10.0342 19.6665C10.1382 18.8951 10.4459 18.3689 10.7878 18.0702C8.12222 17.7684 5.31483 16.7443 5.29076 12.1708C5.2839 10.8672 5.74629 9.80152 6.50989 8.96619C6.3838 8.66445 5.96641 7.45009 6.61027 5.80766C6.61027 5.80766 7.61658 5.4866 9.9167 7.03094C10.8723 6.76636 11.8976 6.63408 12.9191 6.62962C13.9376 6.63556 14.9658 6.76636 15.9257 7.03242C18.2081 5.48809 19.2163 5.80914 19.2163 5.80914C19.8789 7.45306 19.4743 8.66594 19.3529 8.96767C20.1268 9.80301 20.5959 10.8687 20.6028 12.1723C20.6269 16.7577 17.8272 17.767 15.1558 18.0628C15.5882 18.4314 15.976 19.1597 15.9819 20.273C15.9903 21.8693 15.9821 23.1565 15.9841 23.5474C15.9858 23.867 16.2038 24.2386 16.8122 24.1212C21.5663 22.5397 24.9778 18.0672 24.95 12.7951C24.9153 6.20154 19.5142 0.856567 12.8857 0.856567Z"
fill="#151512"
/>
</svg>
</a>
</li>
<li>
<a href="https://discord.gg/PQFdubGt6d" target="_blank" rel="noopener noreferrer">
<svg width="25" height="21" viewBox="0 0 25 21" fill="none" xmlns="http://www.w3.org/2000/svg" class="hover:opacity-50">
<path
d="M22.7861 9.04256C21.8482 5.74455 20.7799 4.04048 20.7627 4.00991C20.7017 3.93459 19.189 2.104 15.5271 0.75L15.0353 2.0764C16.7774 2.72057 18.0116 3.50643 18.6899 4.01419C16.6599 3.40408 14.2431 3.03041 12.1008 3.03041C9.95851 3.03041 7.53775 3.40408 5.50128 4.01419C6.18496 3.50648 7.42744 2.72057 9.17631 2.0764L8.69846 0.75C5.02238 2.104 3.49044 3.93459 3.42863 4.00991C3.41108 4.04048 2.32479 5.74455 1.35221 9.04256C0.414855 12.2208 0.0415214 16.7045 0.027872 16.8843C0.109225 17.0131 1.97891 20.25 7.12077 20.25L8.43406 18.3536C6.97595 17.964 5.58693 17.3357 4.31689 16.4832L5.10228 15.3069C7.15122 16.6822 9.54509 17.4092 12.0251 17.4092C14.5051 17.4092 16.9067 16.6822 18.9701 15.3069L19.7431 16.4832C18.4641 17.3357 17.0684 17.964 15.6062 18.3536L16.8995 20.25C22.0414 20.25 23.9452 17.0131 24.0279 16.8843C24.0161 16.7045 23.69 12.2208 22.7861 9.04256ZM8.79853 12.7392H7.39228L7.40468 10.3841H8.81093L8.79853 12.7392ZM16.7071 12.7392H15.3008L15.3132 10.3841H16.7195L16.7071 12.7392Z"
fill="#151512"
/>
</svg>
</a>
</li>
</ul>
</nav>
</div>
</div>
</div>
</header>
<main class="bg-white text-black flex flex-col"><section class="container max-w-screen-xl flex flex-col items-center pt-10 pb-0 md:pb-10 lg:pb-0">
<div class="info-block max-w-680 pb-5 sm:pb-10 overflow-hidden">
<div class="post mb-10">
<h1 class="text-xl md:text-xxl mb-5 sm:max-w-md lg:max-w-2xl">Waku v1 vs Waku v2: Bandwidth Comparison</h1>
<div>
<span class="text-s lg:text-base"> 03 Nov 2021 • by </span>
<a href="/authors/hanno" class="text-s lg:text-base font-bold hover:underline">hanno</a>
</div>
</div>
<div class="post__content"><h2 id="background">Background</h2>
<p>The <a href="https://vac.dev/waku-v2-plan">original plan</a> for Waku v2 suggested theoretical improvements in resource usage over Waku v1,
mainly as a result of the improved amplification factors provided by GossipSub.
In its turn, <a href="https://vac.dev/fixing-whisper-with-waku">Waku v1 proposed improvements</a> over its predecessor, Whisper.</p>
<p>Given that Waku v2 is aimed at resource restricted environments,
we are specifically interested in its scalability and resource usage characteristics.
However, the theoretical performance improvements of Waku v2 over Waku v1,
has never been properly benchmarked and tested.</p>
<p>Although were working towards a full performance evaluation of Waku v2,
this would require significant planning and resources,
if it were to simulate “real world” conditions faithfully and measure bandwidth and resource usage across different network connections,
robustness against attacks/losses, message latencies, etc.
(There already exists a fairly comprehensive <a href="https://research.protocol.ai/publications/gossipsub-v1.1-evaluation-report/vyzovitis2020.pdf">evaluation of GossipSub v1.1</a>,
on which <a href="https://rfc.vac.dev/spec/11/"><code class="highlighter-rouge">11/WAKU2-RELAY</code></a> is based.)</p>
<p>As a starting point,
this post contains a limited and local comparison of the <em>bandwidth</em> profile (only) between Waku v1 and Waku v2.
It reuses and adapts existing network simulations for <a href="https://github.com/status-im/nim-waku/blob/master/waku/v1/node/quicksim.nim">Waku v1</a> and <a href="https://github.com/status-im/nim-waku/blob/master/waku/v2/node/quicksim2.nim">Waku v2</a>
and compares bandwidth usage for similar message propagation scenarios.</p>
<h2 id="theoretical-improvements-in-waku-v2">Theoretical improvements in Waku v2</h2>
<p>Messages are propagated in Waku v1 using <a href="https://en.wikipedia.org/wiki/Flooding_(computer_networking)">flood routing</a>.
This means that every peer will forward every new incoming message to all its connected peers (except the one it received the message from).
This necessarily leads to unnecessary duplication (termed <em>amplification factor</em>),
wasting bandwidth and resources.
Whats more, we expect this effect to worsen the larger the network becomes,
as each <em>connection</em> will receive a copy of each message,
rather than a single copy per peer.</p>
<p>Message routing in Waku v2 follows the <code class="highlighter-rouge">libp2p</code> <em>GossipSub</em> protocol,
which lowers amplification factors by only sending full message contents to a subset of connected peers.
As a Waku v2 network grows, each peer will limit its number of full-message (“mesh”) peerings -
<code class="highlighter-rouge">libp2p</code> suggests a maximum of <code class="highlighter-rouge">12</code> such connections per peer.
This allows much better scalability than a flood-routed network.
From time to time, a Waku v2 peer will send metadata about the messages it has seen to other peers (“gossip” peers).</p>
<p>See <a href="https://hackmd.io/@vac/main/%2FYYlZYBCURFyO_ZG1EiteWg#11WAKU2-RELAY-gossipsub">this explainer</a> for a more detailed discussion.</p>
<h2 id="methodology">Methodology</h2>
<p>The results below contain only some scenarios that provide an interesting contrast between Waku v1 and Waku v2.
For example, <a href="https://en.wikipedia.org/wiki/Star_network">star network topologies</a> do not show a substantial difference between Waku v1 and Waku v2.
This is because each peer relies on a single connection to the central node for every message,
which barely requires any routing:
each connection receives a copy of every message for both Waku v1 and Waku v2.
Hybrid topologies similarly show only a difference between Waku v1 and Waku v2 for network segments with <a href="https://en.wikipedia.org/wiki/Mesh_networking">mesh-like connections</a>,
where routing decisions need to be made.</p>
<p>For this reason, the following approach applies to all iterations:</p>
<ol>
<li>Simulations are run <strong>locally</strong>.
This limits the size of possible scenarios due to local resource constraints,
but is a way to quickly get an approximate comparison.</li>
<li>Nodes are treated as a <strong>blackbox</strong> for which we only measure bandwidth,
using an external bandwidth monitoring tool.
In other words, we do not consider differences in the size of the envelope (for v1) or the message (for v2).</li>
<li>Messages are published at a rate of <strong>50 new messages per second</strong> to each network,
except where explicitly stated otherwise.</li>
<li>Each message propagated in the network carries <strong>8 bytes</strong> of random payload, which is <strong>encrypted</strong>.
The same symmetric key cryptographic algorithm (with the same keys) are used in both Waku v1 and v2.</li>
<li>Traffic in each network is <strong>generated from 10 nodes</strong> (randomly-selected) and published in a round-robin fashion to <strong>10 topics</strong> (content topics for Waku v2).
In practice, we found no significant difference in <em>average</em> bandwidth usage when tweaking these two parameters (the number of traffic generating nodes and the number of topics).</li>
<li>Peers are connected in a decentralized <strong>full mesh topology</strong>,
i.e. each peer is connected to every other peer in the network.
Waku v1 is expected to flood all messages across all existing connections.
Waku v2 gossipsub will GRAFT some of these connections for full-message peerings,
with the rest being gossip-only peerings.</li>
<li>After running each iteration, we <strong>verify that messages propagated to all peers</strong> (comparing the number of published messages to the metrics logged by each peer).</li>
</ol>
<p>For Waku v1, nodes are configured as “full” nodes (i.e. with full bloom filter),
while Waku v2 nodes are <code class="highlighter-rouge">relay</code> nodes, all subscribing and publishing to the same PubSub topic.</p>
<h2 id="network-size-comparison">Network size comparison</h2>
<h3 id="iteration-1-10-nodes">Iteration 1: 10 nodes</h3>
<p>Lets start with a small network of 10 nodes only and see how Waku v1 bandwidth usage compares to that of Waku v2.
At this small scale we dont expect to see improved bandwidth usage in Waku v2 over Waku v1,
since all connections, for both Waku v1 and Waku v2, will be full-message connections.
The number of connections is low enough that Waku v2 nodes will likely GRAFT all connections to full-message peerings,
essentially flooding every message on every connection in a similar fashion to Waku v1.
If our expectations are confirmed, it helps validate our methodology,
showing that it gives more or less equivalent results between Waku v1 and Waku v2 networks.</p>
<p><img src="/assets/img/waku1-vs-waku2/waku1-vs-waku2-10-nodes.png" alt="" /></p>
<p>Sure enough, the figure shows that in this small-scale setup,
Waku v1 actually has a lower per-peer bandwidth usage than Waku v2.
One reason for this may be the larger overall proportion of control messages in a gossipsub-routed network such as Waku v2.
These play a larger role when the total network traffic is comparatively low, as in this iteration.
Also note that the average bandwidth remains more or less constant as long as the rate of published messages remains stable.</p>
<h3 id="iteration-2-30-nodes">Iteration 2: 30 nodes</h3>
<p>Now, lets run the same scenario for a larger network of highly-connected nodes, this time consisting of 30 nodes.
At this point, the Waku v2 nodes will start pruning some connections to limit the number of full-message peerings (to a maximum of <code class="highlighter-rouge">12</code>),
while the Waku v1 nodes will continue flooding messages to all connected peers.
We therefore expect to see a somewhat improved bandwidth usage in Waku v2 over Waku v1.</p>
<p><img src="/assets/img/waku1-vs-waku2/waku1-vs-waku2-30-nodes.png" alt="" /></p>
<p>Bandwidth usage in Waku v2 has increased only slightly from the smaller network of 10 nodes (hovering between 2000 and 3000 kbps).
This is because there are only a few more full-message peerings than before.
Compare this to the much higher increase in bandwidth usage for Waku v1, which now requires more than 4000 kbps on average.</p>
<h3 id="iteration-3-50-nodes">Iteration 3: 50 nodes</h3>
<p>For an even larger network of 50 highly connected nodes,
the divergence between Waku v1 and Waku v2 is even larger.
The following figure shows comparative average bandwidth usage for a throughput of 50 messages per second.</p>
<p><img src="/assets/img/waku1-vs-waku2/waku1-vs-waku2-50-nodes.png" alt="" /></p>
<p>Average bandwidth usage (for the same message rate) has remained roughly the same for Waku v2 as it was for 30 nodes,
indicating that the number of full-message peerings per node has not increased.</p>
<h3 id="iteration-4-85-nodes">Iteration 4: 85 nodes</h3>
<p>We already see a clear trend in the bandwidth comparisons above,
so lets confirm by running the test once more for a network of 85 nodes.
Due to local resource constraints, the effective throughput for Waku v1 falls to below 50 messages per second,
so the v1 results below have been normalized and are therefore approximate.
The local Waku v2 simulation maintains the message throughput rate without any problems.</p>
<p><img src="/assets/img/waku1-vs-waku2/waku1-vs-waku2-85-nodes.png" alt="" /></p>
<h3 id="iteration-5-150-nodes">Iteration 5: 150 nodes</h3>
<p>Finally, we simulate message propagation in a network of 150 nodes.
Due to local resource constraints, we run this simulation at a lower rate -
35 messages per second -
and for a shorter amount of time.</p>
<p><img src="/assets/img/waku1-vs-waku2/waku1-vs-waku2-150-nodes.png" alt="" /></p>
<p>Notice how the Waku v1 bandwidth usage is now more than 10 times worse than that of Waku v2.
This is to be expected, as each Waku v1 node will try to flood each new message to 149 other peers,
while the Waku v2 nodes limit their full-message peerings to no more than 12.</p>
<h3 id="discussion">Discussion</h3>
<p>Lets summarize average bandwidth growth against network growth for a constant message propagation rate.
Since we are particularly interested in how Waku v1 compares to Waku v2 in terms of bandwidth usage,
the results are normalised to the Waku v2 average bandwidth usage for each network size.</p>
<p><img src="/assets/img/waku1-vs-waku2/waku1-vs-waku2-overall-network-size.png" alt="" /></p>
<p>Extrapolation is a dangerous game,
but its safe to deduce that the divergence will only grow for even larger network topologies.
Although control signalling contributes more towards overall bandwidth for Waku v2 networks,
this effect becomes less noticeable for larger networks.
For network segments with more than ~18 densely connected nodes,
the advantage of using Waku v2 above Waku v1 becomes clear.</p>
<h2 id="network-traffic-comparison">Network traffic comparison</h2>
<p>The analysis above controls the average message rate while network size grows.
In reality, however, active users (and therefore message rates) are likely to grow in conjunction with the network.
This will have an effect on bandwidth for both Waku v1 and Waku v2, though not in equal measure.
Consider the impact of an increasing rate of messages in a network of constant size:</p>
<p><img src="/assets/img/waku1-vs-waku2/waku1-vs-waku2-overall-message-rate.png" alt="" /></p>
<p>The <em>rate</em> of increase in bandwidth for Waku v2 is slower than that for Waku v1 for a corresponding increase in message propagation rate.
In fact, for a network of 30 densely-connected nodes,
if the message propagation rate increases by 1 per second,
Waku v1 requires an increased average bandwidth of almost 70kbps at each node.
A similar traffic increase in Waku v2 requires on average 40kbps more bandwidth per peer, just over half that of Waku v1.</p>
<h2 id="conclusions">Conclusions</h2>
<ul>
<li><strong>Waku v2 scales significantly better than Waku v1 in terms of average bandwidth usage</strong>,
especially for densely connected networks.</li>
<li>E.g. for a network consisting of <strong>150</strong> or more densely connected nodes,
Waku v2 provides more than <strong>10x</strong> better average bandwidth usage rates than Waku v1.</li>
<li>As the network continues to scale, both in absolute terms (number of nodes) and in network traffic (message rates) the disparity between Waku v2 and Waku v1 becomes even larger.</li>
</ul>
<h2 id="future-work">Future work</h2>
<p>Now that weve confirmed that Waku v2s bandwidth improvements over its predecessor matches theory,
we can proceed to a more in-depth characterisation of Waku v2s resource usage.
Some questions that we want to answer include:</p>
<ul>
<li>What proportion of Waku v2s bandwidth usage is used to propagate <em>payload</em> versus bandwidth spent on <em>control</em> messaging to maintain the mesh?</li>
<li>To what extent is message latency (time until a message is delivered to its destination) affected by network size and message rate?</li>
<li>How <em>reliable</em> is message delivery in Waku v2 for different network sizes and message rates?</li>
<li>What are the resource usage profiles of other Waku v2 protocols (e.g.<a href="https://rfc.vac.dev/spec/12/"><code class="highlighter-rouge">12/WAKU2-FILTER</code></a> and <a href="https://rfc.vac.dev/spec/19/"><code class="highlighter-rouge">19/WAKU2-LIGHTPUSH</code></a>)?</li>
</ul>
<p>Our aim is to get ever closer to a “real world” understanding of Waku v2s performance characteristics,
identify and fix vulnerabilities
and continually improve the efficiency of our suite of protocols.</p>
<h2 id="references">References</h2>
<ul>
<li><a href="https://research.protocol.ai/publications/gossipsub-v1.1-evaluation-report/vyzovitis2020.pdf">Evaluation of GossipSub v1.1</a></li>
<li><a href="https://vac.dev/fixing-whisper-with-waku">Fixing Whisper with Waku</a></li>
<li><a href="https://hackmd.io/@vac/main/%2FYYlZYBCURFyO_ZG1EiteWg#11WAKU2-RELAY-gossipsub">GossipSub vs flood routing</a></li>
<li><a href="https://www.techopedia.com/definition/13335/star-topology#:~:text=Star%20topology%20is%20a%20network,known%20as%20a%20star%20network.">Network topologies: star</a></li>
<li><a href="https://en.wikipedia.org/wiki/Mesh_networking">Network topologies: mesh</a></li>
<li><a href="https://vac.dev/waku-v2-plan">Waku v2 original plan</a></li>
</ul>
</div>
</div>
</section>
</main>
</div>
<footer class="footer bg-black flex flex-shrink-0 justify-center">
<div class="container max-w-screen-xl flex sl:justify-between lm:justify-start p-5 md:px-12 md:pt-5 lg:py-10">
<div class="logo mr-10 sm:mr-0 sm:w-2/12 lg:w-3/12">
<a href="/"><img src="/assets/img/logo.png" alt="Vac logo" class="w-9 h-11" /></a>
</div>
<div class="flex flex-col xm:flex-row xm:justify-between sm:w-10/12 lg:w-9/12">
<p class="hidden sl:inline-block sl:mr-10 text-xxs lg:text-base text-white opacity-75">Vac researches peer-to-peer, private, censorship resistant communication</p>
<nav class="flex max-w-xs mr-0 xm:mr-5 l:mr-32 mb-5 sm:mb-0">
<div class="flex">
<div class="flex flex-col mr-5 sm:mr-10 sl:mr-14">
<p class="text-xxs lg:text-base text-white opacity-75 mb-5 lg:mb-8">Research</p>
<ul>
<li class="text-xxs lg:text-base text-white hover:opacity-50 mb-5">
<a href="/research-log" target="_blank" rel="noopener noreferrer">Log</a>
</li>
<li class="text-xxs lg:text-base text-white hover:opacity-50 mb-5">
<a href="https://rfc.vac.dev/" target="_blank" rel="noopener noreferrer">Specs</a>
</li>
</ul>
</div>
<div class="flex flex-col sl:mr-14">
<p class="text-xxs lg:text-base text-white opacity-75 mb-5 lg:mb-8">Socials</p>
<ul>
<li class="text-xxs lg:text-base text-white hover:opacity-50 mb-5">
<a href="https://twitter.com/vacp2p" target="_blank" rel="noopener noreferrer">Twitter</a>
</li>
<li class="text-xxs lg:text-base text-white hover:opacity-50 mb-5">
<a href="https://discord.gg/PQFdubGt6d" target="_blank" rel="noopener noreferrer">Discord</a>
</li>
<li class="text-xxs lg:text-base text-white hover:opacity-50 mb-5">
<a href="https://t.me/vacp2p" target="_blank" rel="noopener noreferrer">Telegram</a>
</li>
</ul>
</div>
</div></nav></div>
</div>
</footer>
<script src="/assets/js/main.min.js"></script>
<script src="/assets/js/smooth-scroll.min.js"></script>
</body>
</html>