Random thoughs about software development

Fail Fast Principle

In one of the previous posts I talked about circut breaker and timeout patterns as a way of improving the stability of your application. In this blog post I will talk about a pattern that complements the previous ones - Fail Fast.

This pattern is also taken from the excellent Release It!Design and Deploy Production-Ready Software book and I recommend that you will read it.

It is a very simple principle and it’s based on common sense - if the system can determine in advance that it won’t be able to succeed, it’s always better to fail fast.

Thanks to this you don’t have to block any resources and those resources can be used to complete a more meaningful job.

How to apply Fail Fast Principle

It doesn’t mean that your system has to introduce some fancy machine learning algorithms to figure out if the request will succeed.

It’s actually much simpler than this - you can, for example, check if all integration points needed for this tasks are working properly. You can do this by verifying the state of circut breakers for those integration points.

Another way to fail fast is performing basic parameter checking before calling an actual action. You can verify up front if all needed parameters are present or if they are incorrect format. Word of warning here - make sure you do only sanity check type validation here. Any business logic specific validation should belong to some kind of domain specific object - otherwise, the rule encapsulation would be violated.

Reporting a system failure

Import thing when you apply Fail Fast Principle is correct failure reporting. You should make sure that system failures (database or network is unavailable, some external service is down etc) are reported differently than application failures (when the user submits invalid parameters). In particular, invalid input should never change the state of any circut breaker.

How does it work with Circut Breakers and Timeouts?

As I mentioned before - Fail Fast works as a complement of Circut Breaker and Timeout patterns. Both helps you deal prevent cascading failures. Circut Breaker and Timeout deal with incoming requests by giving up when appropriate. For incoming requests you should Fail Fast if you are not able to process the request.


Fail Fast is a great pattern that can significantly improve the stability of your system by preventing long responses. Long responses can lead to cascading failures, which is the worst scenario for any application. They can also improve capacity of your system by avoiding using up resources on tasks that won’t succeed anyway

Written on May 1, 2017