When the first name server in /etc/resolv.conf stops answering, every lookup waits for it before it tries the next one. By default that wait is five seconds per try.
The man page lists the defaults: timeout is 5 seconds and attempts is 2. With two dead servers, a single lookup can hang for a long time, and every program on the box feels frozen. You can make that shorter with an options line:
nameserver 192.0.2.53
nameserver 203.0.113.53
options timeout:2 attempts:2 rotate
timeout:2 waits two seconds per server and attempts:2 runs the round twice. rotate spreads lookups over the servers instead of always asking the first one first. The glibc resolver caps the values silently: timeout at 30 and attempts at 5. It also reads only the first three nameserver lines.
Before you edit the file, check what writes it:
ls -l /etc/resolv.conf
On many systems it is a symlink managed by systemd-resolved, NetworkManager or resolvconf, and your change will be overwritten. With systemd-resolved the file usually lists only the local stub at 127.0.0.53, and the timeouts toward the real servers are handled by resolved itself, so these options make little difference there. I think they fit plain servers and containers best, where resolv.conf really is the whole story.
Further reading: resolv.conf(5) manual page