Firebase Load Testing : <p><strong>How can we load test Firebase Realtime Database listener performance?</strong></p>

<p>Firebase Realtime Database documentation says that we can have up to 100K concurrent users per database. If we have 100K concurrent users listening to the same node in a database, and that node updates, how quickly will the 100K users be notified of that update? (Obviously with just a few users, users are notified in less than a second, but how would it perform with 100K users listening at the same node?)</p>

<p>We're trying to simulate 100K concurrent users listening on the same path. </p>

<p><strong>What We've Tried</strong></p>

<p><em>Attempt #1</em>: We tried using a for loop to attach 100K listeners, but those listeners are pipelined over the same socket, so Firebase only sees one listener. <em>Is there a way we can disable pipelining of listeners?</em></p>

<p><em>Attempt #2</em>: Per this <a href="https://www.viget.com/articles/backend-as-a-service-at-scale/" rel="noreferrer">article</a> from Viget, we used a node script to spawn several child processes, each of which attaches a single listener to Firebase. See code below (from Viget). Unfortunately this isn't scalable to 100K - we can only realistically create a small handful of child processes per machine (generally equal to the number of CPUs the machine has). <em>Is there a way we can spawn significantly more child processes per machine (either with node, or something else)?</em></p>

<pre><code>const spawn = require('child_process').spawn

// How many connections to build with Firebase
const maxChildren = {# of CPUs the machine has}

// How long to keep child processes alive
const timeout = 10 * 60 * 1000 // 10 minutes

for (var i = 0; i &lt; maxChildren; i++) {
    // your-test.js should contain your application-specific test
    var child = spawn('node', ['your-test.js', `--id=${i}`, '-- timeout=${timeout}'])

    child.stdout.on('data', (data) =&gt; {
        console.log(`stdout: ${data}`)
    });

    child.stderr.on('data', (data) =&gt; {
        console.log(`stderr: ${data}`)
    });

    child.on('close', (code) =&gt; {
        if (code !== 0) console.log(`Child ${i} process exited with an error. Code ${code}`)
    })
}
</code></pre>

<p>I'm sure the engineers at Firebase must do some load testing, since there has to be a basis for the 100K concurrent connection limit. Does anyone have insight into the tools they use?</p>
