4 ms·
Checking responses in production is also a good idea because it reveals all the edges that may not be exercised in an artificial test suite. There is still som
by brandur 8y ago
Checking responses in production is also a good idea because it reveals all the edges that may not be exercised in an artificial test suite.
There is still some performance cost for checking a response against a schema though, so a nice compromise is just to check a small % of outgoing responses — the vast majority of requests stay as fast as possible, but given a reasonable traffic load, it's still enough to eventually reveal any places the schema doesn't match reality. (This is an approach we use at Stripe for checking our OpenAPI specification.)
- sbr464 8y agoSide note @brandur, I always look forward to your blog posts, time for a new one!
- brandur 8y agoHah, thanks! :) I'll got a few queued up that I hope to get finished up pretty soon.
- foxtacles 8y agoWe are also validating responses against JSON schemas in our Ruby production apps. I can confirm it's a very helpful practice and I'm a big fan of it. Currently we are checking 100% of the responses. I even wrote this gem which uses native code to perform the schema validation to minimize the overhead in our endpoints: https://github.com/foxtacles/rj_schema https://github.com/foxtacles/rj_schema Validating our largest and most complex responses is taking <10ms, on average no more than 2-5ms which is quite affordable.