I'm passing a handful of STUN and TURN servers for my WebRTC application (built on top of mediasoup). When I do this, I get a message in the console telling me: "Using more than two STUN/TURN servers slows down discovery"
I can cut down the servers to 2... but... why does more hurt? Wouldn't I want the most options available to make a connection?
Because how ICE works is that initially the browser looks at what IP based network interfaces it can find on your machine.
Then it takes the number of network interfaces and combines it with ever single STUN server and every single TURN server the service provides. Next it needs to send request to every single of the these combinations and keep track of the responses. In case of STUN it's just a single response, in case of TURN it is usually multiple round trips. So the more STUN and TURN servers you have the longer it takes to get answers from all of them.
Now if STUN server #1 reports your external IP address as A, with port 1, most likely STUN server #2 is also going to tell you it sees A as your external IP address, with the only difference it reports port 2. In almost all cases all the STUN servers are going to report back the exact same external IP A. But reporting the same external IP address over and over again to the ICE agent on the other end does not increase the chances of establishing the connection at all since its request are all going to hit the same router/NAT/firewall.
With TURN servers one can argue that more TURN servers could help more, as each TURN server should give the browser a different IP address for relaying. But it would be highly unusual if a given browser is able to reach one TURN server and not the another.
In the end all of these servers result in the browser emitting more ICE candidates. And so more ICE candidates need to get send to the other browser or ICE agent. As a result the ICE checking table which tries all possible permutations of local and remote ICE candidates grows bigger and bigger with each ICE candidate. And so it produces a lot more network traffic, while not much increasing the chances of establishing a connection.