:thread: rate limiting
# help
p
🧵 rate limiting
Does wiremock supports rate limiting functionality out of the box? I don't see this in the docs
l
Hi, I don't think this is supported out of the box. Should be pretty straight forward via an extension though
p
Thanks for the response. Is there a place where I can see all the extensions?
l
Unfortunately not. We were working on a new docs site that would include the extensions alongside our core docs but this got delayed. I haven't seen a rate limiting extension to be honest but like I said, it shouldn't be too hard to implement a WireMock request filter to do this. We host a number of extensions on the wiremock github org - https://github.com/wiremock There is also the wiremock-extension topic on github - https://github.com/topics/wiremock-extension
Can I ask what the use case is for this? Are you just wanting to rate limit your wiremock instance or are you wanting to test some code that can be rate limited and you want to use wiremock to send back rate limited responses?
p
I want wiremock to return rate limited responses for a subset of request on a random basis so that we can test application server's ability to handle such situtations.
l
A rate limited response would be easy enough to stub out. The random part might be a little more tricky though. You might need to combine two stubs - one for the happy path response and one for the rate limited response. You then might need the state extension to manage some state that is used to determine which one of those stubs is matched? https://github.com/wiremock/wiremock-state-extension
This might be one of those instances where WireMock Cloud might be a better fit. Cloud has a chaos mode where you can specify a http status to be returned on a percentage of responses? Not sure if that would be a better fit for you but might be worth a look
More information about WM Cloud can be found here - https://www.wiremock.io/comparison
p
thanks for the suggestion, will take a look