Building Software That Survives Failure

Why reliable systems must be designed for unexpected conditions, safe recovery, and long-term operational resilience.

Software is often evaluated by how well it performs when everything works as expected.

Applications respond to requests, databases store information, and services communicate without interruption.

During development, these successful interactions provide reassurance that a system is functioning correctly.

But real-world environments are rarely predictable.

Network connections fail. External services become unavailable. Databases encounter errors, and unexpected inputs expose weaknesses in application logic.

Some failures are temporary. Others create uncertainty about whether an operation was completed.

For developers and business leaders, these situations raise an important question.

What happens to a software system when something goes wrong?

The answer reveals a great deal about its engineering quality.

Reliability Begins With Accepting Failure

Every software system depends on components that can fail.

A web application may rely on cloud infrastructure, payment providers, authentication services, and external APIs.

Even when individual components are highly reliable, the complete system must account for interruptions and unexpected behavior.

Reliable engineering begins by identifying these dependencies and understanding their possible failure modes.

A payment service might become temporarily unreachable.

A database transaction could fail halfway through an operation.

A network timeout may prevent an application from receiving confirmation that a request was processed successfully.

Developers must determine how the application should respond to these conditions.

Should it retry?

Should it stop processing?

Can it restore a previous state?

Does the operation require human intervention?

These questions belong in architectural planning because the answers affect data integrity, security, and business continuity.

Why Network Timeouts Are More Complicated Than They Appear

One of the most common problems in distributed software is the network timeout.

A client sends a request to another service but does not receive a response within the expected time.

At first glance, the solution may seem straightforward: send the request again.

However, the situation can be more complicated.

The receiving service may have completed the original operation before the connection was interrupted.

Consider an online payment.

A customer submits an order, and the payment service successfully processes the transaction.

Before confirmation reaches the application, the network connection fails.

The application now faces an ambiguous outcome.

If it automatically repeats the payment request without appropriate protection, the customer could be charged twice.

Amazon Web Services addresses this problem through idempotent API design.

An idempotent operation can be repeated without producing additional unintended effects from the same logical request.

For business-critical operations, unique request identifiers and appropriate server-side safeguards can help prevent duplicate execution.

The important principle is that a missing response does not necessarily mean the original operation failed.

The Danger of Uncontrolled Retries

Retries are useful for handling temporary failures.

A service experiencing a brief interruption may recover before a second request arrives.

However, uncontrolled retries can create additional problems.

Imagine an application experiencing thousands of failed requests because a database has become overloaded.

If every request is immediately repeated, the additional traffic may prevent the database from recovering.

When multiple services independently retry failed operations, the resulting traffic can multiply across the system.

AWS recommends controlled retry strategies, including exponential backoff and jitter.

Exponential backoff increases the delay between successive attempts.

Jitter introduces variation into those delays, helping prevent many clients from retrying simultaneously.

Microsoft’s Azure Architecture Center also recommends the Circuit Breaker pattern for situations in which a dependency continues failing.

A circuit breaker temporarily prevents repeated requests to an unavailable service, allowing the system to respond in a controlled manner.

These mechanisms must be selected according to the type of operation.

Retries are appropriate only when their effects are understood and repeated execution can be handled safely.

Data Integrity Must Survive Unexpected Interruptions

Reliability is closely connected to data integrity.

A system should avoid leaving business information in an inconsistent state when processing is interrupted.

Consider an e-commerce application.

A customer places an order.

The system must record the purchase, update inventory, initiate payment processing, and prepare fulfillment.

These activities may involve separate services.

What happens if inventory is reduced but the order cannot be completed?

What if payment succeeds while fulfillment fails?

A reliable architecture must define how incomplete workflows are detected and resolved.

Within a transactional database, atomic operations can ensure that related changes are committed together or rolled back when necessary.

Distributed workflows introduce additional challenges because a single transaction may not cover every service.

One approach is the Saga pattern, in which a process consists of multiple coordinated steps with explicitly defined recovery actions.

Microsoft documents compensating transactions as a technique for addressing partially completed workflows.

However, compensation is not always equivalent to reversing time.

Some actions cannot be fully undone.

A shipment that has already left a warehouse, for example, requires a different recovery process from an uncommitted database update.

Reliable systems must account for these practical limitations.

Security and Failure Handling Are Connected

Unexpected failures can also expose security weaknesses.

A system might correctly enforce authorization during normal operation but behave differently when a dependency fails.

For example, an application could lose access to its authorization service during a sensitive operation.

The appropriate response depends on the system’s design, but security-critical actions generally require safe denial when authorization cannot be established.

Developers should avoid designs where an error, timeout, or exception accidentally bypasses a required security check.

Critical workflows also need to preserve appropriate records of attempted actions and their outcomes.

This becomes especially important when an application handles financial transactions, sensitive data, or privileged administrative commands.

The NIST Secure Software Development Framework emphasizes integrating security practices throughout the development lifecycle.

For developers, this includes identifying risks, establishing security requirements, and verifying that the implemented software behaves as intended.

Reliable failure handling supports these objectives by ensuring that unexpected conditions do not undermine established protections.

Testing Beyond the Successful Scenario

Traditional functional tests often focus on expected behavior.

A valid request should produce the correct response.

A completed transaction should update the relevant records.

A user with appropriate permissions should be able to access an authorized resource.

These tests are necessary, but they provide only part of the evidence needed to establish reliability.

A more comprehensive testing strategy deliberately examines failure conditions.

Examples include:

  • Interrupting network connections during important operations.
  • Simulating unavailable databases or external services.
  • Supplying invalid or unexpected inputs.
  • Testing repeated requests and duplicate messages.
  • Introducing failures before and after transaction commits.
  • Simulating service shutdowns while operations are in progress.
  • Testing concurrent operations that affect shared data.

Each scenario should have an expected outcome.

For example, a failed authorization check should prevent the protected operation.

A repeated payment request should not create an unintended duplicate charge.

An interrupted transaction should produce a defined, recoverable state.

The objective is to verify that failure behavior matches the system’s documented requirements.

What Google SRE Teaches About Cascading Failures

Google’s Site Reliability Engineering guidance provides another important perspective.

An isolated failure can spread when other components depend on the affected service.

A slowing backend may cause requests to accumulate.

As response times increase, applications may create additional retries.

The resulting traffic can place even more pressure on the infrastructure.

This process can contribute to cascading failures.

Google recommends techniques such as load shedding, appropriate timeouts, capacity planning, and testing systems under demanding conditions.

Load shedding allows a service to reject or defer selected requests when continuing to accept them would threaten overall stability.

A system may also temporarily disable nonessential features to preserve critical functionality.

For businesses, this represents an important design principle.

During an incident, maintaining essential operations can be more valuable than attempting to preserve every feature.

Why Observability Matters During Recovery

Even a carefully designed application can encounter unexpected conditions.

When incidents occur, developers need sufficient information to understand what happened.

Logs, metrics, distributed tracing, and operational alerts can help identify the affected components and reconstruct important events.

However, collecting information is only the beginning.

The system should make it possible to distinguish between operations that succeeded, failed, or ended with an uncertain outcome.

This distinction becomes particularly important for financial or state-changing workflows.

An application that simply reports an error without preserving the relevant execution context may make recovery more difficult.

Operational visibility should therefore be considered during architecture design.

Useful evidence includes request identifiers, transaction states, relevant error categories, and records of authorized actions.

Sensitive information must be protected, and logging systems should avoid unnecessarily exposing credentials or personal data.

The purpose of observability is to support accurate diagnosis, accountable operations, and reliable recovery.

A Practical Approach to Resilient Software

For development teams, resilience requires a combination of engineering practices.

1. Identify critical operations

Determine which workflows could cause significant financial, security, or operational consequences if they fail.

2. Define expected failure behavior

Specify how the system responds to timeouts, invalid inputs, interrupted transactions, and unavailable dependencies.

3. Protect state-changing operations

Use appropriate transaction boundaries, idempotency controls, and recovery mechanisms.

4. Test realistic failures

Introduce controlled faults and verify that the system preserves important invariants and authorization requirements.

5. Monitor and improve

Review incidents, identify recurring weaknesses, and use the findings to strengthen the architecture.

These practices should be adapted to the system’s complexity and business risks.

A small informational website does not require the same recovery architecture as a financial platform.

Engineering controls should remain proportional to the consequences of failure.

A Founder’s Perspective

From my perspective, reliable software development requires responsibility for what happens beyond the expected operating conditions.

Building digital products involves a continuous series of architectural decisions.

Developers must determine how components interact, which actions are authorized, and what the application should do when assumptions no longer hold.

These decisions influence whether the system can be maintained and expanded safely.

I believe testing unexpected conditions is an essential part of responsible engineering.

It encourages developers to examine questions that are easy to overlook when a feature appears to function correctly.

Can an operation be interrupted safely?

Could a retry create an unintended duplicate action?

Will the application preserve accurate records when a service becomes unavailable?

Does a failed security check reliably prevent execution?

Answering these questions requires deliberate design and meaningful verification.

There is also a business dimension.

Additional testing and architectural improvements require time and resources.

Under development pressure, it can be tempting to postpone this work in favor of releasing new features.

However, unresolved reliability problems can create much greater costs when applications become operationally important.

For entrepreneurs building technology products, engineering discipline is part of long-term business strategy.

The objective should be to create software capable of evolving while maintaining reliable and understandable behavior.

Building Systems That Earn Trust

No complex software system can guarantee that failures will never occur.

Hardware can malfunction, networks can become unavailable, and software defects may remain undiscovered until unusual conditions emerge.

The objective of resilient engineering is to reduce the probability and impact of those failures.

Applications should preserve critical data, enforce security boundaries, and recover through defined mechanisms whenever possible.

Equally important, they must recognize when automated recovery is unsafe and human intervention is required.

As businesses become more dependent on digital systems, these capabilities will increasingly influence operational continuity and customer confidence.

The long-term quality of software is reflected in its ability to operate predictably under uncertainty.

Reliable software is built to handle failure safely, preserve integrity, and recover with confidence.

The true quality of an application becomes visible when something goes wrong.

Leave a Reply