Keep useful service available when dependencies fail
A production AI system must remain predictable when dependencies slow down, inputs are duplicated, traffic spikes, secrets rotate, or a new artifact fails. Reliability means controlling failure—not pretending failure will never happen.
Security, cost, and governance are architectural concerns. A cheap service that exposes personal data is unacceptable; a secure model with no rollback owner is incomplete; an accurate endpoint that collapses during bursts is not reliable.
What You Will Be Able to Explain
- Explain SLI, SLO, and SLA at beginner level
- Design timeout, retry, backpressure, and fallback behaviour
- Map trust and supply-chain boundaries
- Calculate cost per 1,000 predictions
- Connect ownership, approval, audit, incident response, and rollback
Reliability, security and cost in measurable terms
These terms name different responsibilities. Read the meaning before following them through the diagrams and worked example.
Core vocabulary
Reliability has a safe path for overload and dependency failure
Availability is the fraction of intended time or requests that the service can fulfill. Redundancy removes a single point of failure, but duplicate capacity alone is not enough: traffic routing, health checks, data consistency, and recovery must also work.
Every external call needs a timeout. Retry only transient operations that are safe to repeat, use bounded attempts with backoff and jitter, and preserve idempotency for side effects. A circuit breaker stops repeatedly calling a dependency already known to be failing.
Queues smooth short bursts and support asynchronous recovery. Backpressure caps producers or rejects low-priority work when consumers cannot keep up. Graceful degradation returns a safer reduced service—cached eligible results, deterministic rules, or human review—instead of silently guessing.
Graceful degradation keeps failure bounded
What should happen when the primary prediction path is unavailable?
SLI, SLO, and SLA in one example
Failure needs an explicit bounded response
Protect the model, its inputs and the authority to release it
Security applies least privilege to people and services, keeps secrets outside code and client bundles, encrypts sensitive data in transit and at rest, and protects artifact integrity. Checksums, signatures, dependency inventories, and controlled registries reduce model supply-chain risk.
Governance records intended use, owner, risk tier, training lineage, evaluation, approval, model card/documentation, deployed version, incidents, and rollback responsibility. Compliance requirements depend on jurisdiction and use; they must be identified with qualified organizational guidance.
Production ML crosses several trust boundaries
Where must identity, secrets, data, and artifact integrity be enforced?
Worked Example: Compare toy cost per 1,000 predictions
Given: Assume full utilization for one hour. Design A costs $0.80/hour and serves 80 predictions/second. Design B costs $2.00/hour and serves 300 predictions/second. Ignore storage, network, idle time, failures, and other services.
- Design A throughput per hour = 80 × 3,600 = 288,000 predictions.
- Design A cost per 1,000 = $0.80 ÷ (288,000/1,000) = $0.80 ÷ 288 ≈ $0.00278.
- Design B throughput per hour = 300 × 3,600 = 1,080,000 predictions.
- Design B cost per 1,000 = $2.00 ÷ (1,080,000/1,000) = $2.00 ÷ 1,080 ≈ $0.00185.
- Under these toy assumptions B has the lower unit compute cost, despite the higher hourly price. Actual cost depends on utilization, idle capacity, autoscaling, batches, storage, data transfer, and recovery capacity.
Result and interpretation: Cost per prediction is a rate, not the instance price. Design B is cheaper per 1,000 at full utilization, but architecture selection still includes accuracy, latency, reliability, hardware availability, burst traffic, and risk.
The following figures turn the example into an operational decision. Follow every branch and note which state is recorded before work continues.
Higher hourly price can still mean lower unit cost
How do utilization and throughput change cost per 1,000 predictions?
Calculate unit cost and specify bounded failure handling
The label above each block states what it is. Runnable Python can be executed as shown with the standard library; pseudocode and configuration communicate architecture and require adaptation to a real platform.
Route a timed-out prediction safely
Fallback order is a reviewed product policy. It never converts a missing prediction into blind approval.
try:
prediction = model_service.predict(request, timeout_ms=60)
return apply_policy(prediction)
except Timeout:
open_circuit_after_repeated_failures()
if approved_cache.is_fresh_for(request.entity):
return apply_policy(approved_cache.get(request.entity))
if deterministic_rules.can_decide(request):
return deterministic_rules.decide(request)
return route_to_manual_review(reason="model unavailable")Choose safe fallbacks, access boundaries and cost limits
- Choose SLOs from user impact and measurable service behaviour; do not copy a fashionable percentage.
- Reserve capacity and fallbacks according to risk, traffic bursts, and recovery time rather than theoretical average load.
- Calculate cost per accepted useful prediction, including idle and failure overhead—not only raw model calls.
- Assign named owners for data, artifact, release, security, business policy, incident command, and rollback.
Failure Analysis and Recovery
Observed failure → likely cause → controlled response
Connect to Earlier Lessons
- GenAI deployment
Apply these system principles to generative applications.
- Agent security
Study tool and instruction risks specific to agents.
- Agent observability
See trace, latency, and cost evidence for multi-step execution.
Summary / Key Takeaways
- Reliability controls failure through redundancy, deadlines, bounded retries, backpressure, fallbacks, and tested recovery.
- An SLI is a measurement, an SLO is an internal target, and an SLA is an external commitment.
- Retries require transient failure classification, backoff, bounded attempts, and idempotency so they do not amplify harm.
- Least privilege, secret management, encryption, PII controls, and artifact integrity protect the production trust chain.
- At full toy utilization, Design A costs about $0.00278 and Design B about $0.00185 per 1,000 predictions.
- Unit cost alone cannot decide an architecture because accuracy, latency, burst capacity, reliability, and risk also matter.
- Governance makes ownership, intended use, lineage, approval, audit, incident response, and rollback responsibility explicit.