0:00 All right, so in this lecture, we're gonna take a look at implementing 0:03 the circuit 0:03 breaker pattern into our application and understanding 0:07 what this is, how it actually helps us inside of a 0:10 Node.js 0:11 production-grade application using best practices for networking. 0:17 Now, the circuit breaker pattern is named after the electrical device. 0:21 When a current gets dangerous, something trips and cuts the line rather 0:25 than letting the wire burn. In software, the 0:28 current is requests to a dependency that has stopped 0:32 working properly. So essentially, any sort of upstream server that we're 0:35 calling, when that stops responding to us, we want to be able 0:39 to fail fast and actually stop overwhelming that 0:43 system. Now, there's two main benefits we gain from 0:46 this, the first of 0:47 which is resource exhaustion on our side on the application, 0:51 right? Every request that we open up to a server 0:55 is a socket. It is a physical resource 0:59 on the machine that we're opening that consumes memory, CPU, a 1:03 connection pool slot. Essentially, it is 1:07 part of some finite resources, right? 1:08 And so we don't wanna keep opening these up and pooling them and waiting for the 1:12 upstream when we know that it's not responding. 1:15 We're just gonna lead to higher resource usage on our side when we know 1:19 we're not gonna get back a response. 1:22 Now, the other benefit to this is, of course, 1:24 on the server side where the client 1:26 is actually calling. If we continue to hammer a server that's 1:29 already 1:30 overwhelmed with more requests, let's say it's run out of 1:33 memory or CPU, well, throwing more load onto that 1:37 server, of course, we know is just gonna make the problem worse. 1:41 And so the circuit breaker pattern allows us to lighten that load to 1:45 the server so that potentially it might even recover and allow us to
The rest of the transcript is for members.
Sign in