Vladimir Dyuzhev
MockMotor Creator
Simulate Network Failures to Test Resource Shortage Scenarios
Test unexpected connections termination under load
Sometimes, a high load is not a happy place. APIs begin to exhaust available memory and CPUs, slow down, and eventually fail. The API can even begin closing connections at random to survive.
Do you want to verify your application’s behaviour in these conditions?
With MockMotor, you can.
Delay, Read Timeout and Connect Timeout
MockMotor can programmatically increase the mocked API response time based on the load. This handles the “APIs become slow” part.
MockMotor can also simulate a read timeout by setting the delay to a value greater than the client’s configured timeout.
(MockMotor can NOT simulate a configurable connect timeout. To figure out what to do with a request, MockMotor must accept the connection. Alas, there is no way around it.)
There is, however, one more simulated networking failure that MockMotor can do - a connection termination.
HTTP 444: Connection Closed by Remote Host
In this scenario, the client sends a request to MockMotor, which accepts it in full and then unexpectedly closes the connection without reporting an error.
This logic simulates a resource shortage in a backend API.
All you need to do is set HTTP status 444 for the matching reaction. This is a non-standard HTTP code, but it was pioneered and used by Nginx, allegedly because the Chinese number 4 sounds similar to “death.” Or something like that. MockMotor accepts this widely known practice.
Set HTTP status to 444 and enjoy the chaos!
AI created no part of this text. It isn't the Butlerian Jihad, but it is something anyone could do.