惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

N
Netflix TechBlog - Medium
IT之家
IT之家
博客园_首页
Hugging Face - Blog
Hugging Face - Blog
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
美团技术团队
小众软件
小众软件
博客园 - 叶小钗
WordPress大学
WordPress大学
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 三生石上(FineUI控件)
罗磊的独立博客
博客园 - Franky
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Last Week in AI
Last Week in AI
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
宝玉的分享
宝玉的分享
博客园 - 【当耐特】
月光博客
月光博客
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
人人都是产品经理
人人都是产品经理

DEV Community

Authentication Security Deep Dive: From Brute Force to Salted Hashing (With Java Examples) Why AI Systems Don’t Fail — They Drift Spilling beans for how i learn for exam😁"Reinforcement Learning Cheat Sheet" I Replaced Chrome with Safari for AI Browser Automation. Here's What Broke (and What Finally Worked) How Python Borrows Other People's Work The $40 Architecture: Processing 1 Billion API Requests with 99.99% Uptime Vibe Coding: A Workflow Guide (From Zero to SaaS) Most webhook security guides protect the wrong side. The scary part is delivery. Headless CMS for TanStack Start: Build a Blog with Cosmic EU Age Verification App "Hacked in 2 Minutes" — What Actually Happened Comfy Cloud’s delete function does not actually remove files Running AI Models on GPU Cloud Servers: A Beginner Guide Event-driven media intelligence with AWS Step Functions and Bedrock I scored 500 AI prompts across 8 quality dimensions — here's what broke How to Call Google Gemini API from Next.js (Free Tier, No Backend Needed) The Portal Protocol: Reclaiming Human Connection in the Age of AI How to Fix Your Team's Scattered Knowledge Problem With a Self-Hosted Forum Intro to tc Cloud Functors: A Graph-First Mental Model for the Modern Cloud Designing Multi-Tenant Backends With Both Ownership and Team Access I Built a Neumorphic CSS Library with 77+ Components — Here's What I Learned PostgreSQL Performance Optimization: Why Connection Pooling Is Critical at Scale Cómo construí un SaaS multi-rubro para gestionar expensas en Argentina con FastAPI + Vue 3 🚀 I Built an Ethical Hacking Scanner Tool – Open Source Project I Replaced /usage and /context in Claude Code With a Single Statusline A Pythonic Way to Handle Emails (IMAP/SMTP) with Auto-Discovery and AI-Ready Design I Collected 8.9 Million Polymarket Price Points — Here's What I Found About How Markets Really Move EcoTrack AI — Carbon Footprint Tracker & Dashboard Everyone's Using AI. No One Agrees How. 5 self-hosted ebook managers worth trying in 2026 Building Your First AI Agent with LangChain: From Chatbot to Autonomous Assistant
Building a Fault-Tolerant Node.js Backend: 4 Patterns I A...
Shahin Quliy · 2026-04-25 · via DEV Community

Shahin Quliyev

While building iTicket.AZ — a real-time event ticketing platform — I came across a job posting from a major bank that listed "building scalable, resilient, and fault-tolerant applications" as a core requirement. That made me think: is my backend actually fault-tolerant? Spoiler: it wasn't. Here's what I changed.

What does "fault-tolerant" actually mean?

A fault-tolerant system keeps running — even in degraded form — when parts of it fail. That means your app doesn't crash just because the database hiccuped, a third-party API timed out, or a job queue backed up. There are four patterns I focused on.

Pattern 1 — Retry + Circuit Breaker

When a DB write fails, should we silently drop it? No — but we also shouldn't hammer a broken service forever. The retry pattern tries again a few times; the circuit breaker stops calls entirely after too many failures.

import CircuitBreaker from 'opossum';

const dbOptions = {
  timeout: 3000,
  errorThresholdPercentage: 50,
  resetTimeout: 30000,
};

const breaker = new CircuitBreaker(saveTicketToDB, dbOptions);

breaker.fallback(() => ({
  success: false,
  message: 'Service temporarily unavailable. Try again shortly.'
}));

export const createTicket = async (data) => {
  return await breaker.fire(data);
};

Enter fullscreen mode Exit fullscreen mode

Now instead of hanging requests, your users get a clean error immediately. Library: opossum.

Pattern 2 — Graceful Degradation

If the chat service (Socket.IO) goes down, should ticket purchasing stop too? Absolutely not. Each feature should fail independently.

export const getEventDetails = async (eventId: string) => {
  const [event, chatStatus] = await Promise.allSettled([
    EventService.findById(eventId),
    ChatService.getStatus(eventId),
  ]);

  return {
    event: event.status === 'fulfilled' ? event.value : null,
    chatAvailable: chatStatus.status === 'fulfilled',
  };
};

Enter fullscreen mode Exit fullscreen mode

Promise.allSettled is the key here — unlike Promise.all, it doesn't throw if one promise rejects.

Pattern 3 — Health Checks + Structured Logging

app.get('/health', async (req, res) => {
  const checks = {
    database: await checkDB(),
    uptime: process.uptime(),
    timestamp: new Date().toISOString(),
  };
  const allOk = Object.values(checks).every(Boolean);
  res.status(allOk ? 200 : 503).json(checks);
});

const log = (level: string, message: string, meta = {}) => {
  console.log(JSON.stringify({
    level, message, ...meta,
    service: 'iticket-api',
    ts: new Date().toISOString(),
  }));
};

Enter fullscreen mode Exit fullscreen mode

Pattern 4 — Queue + Async Processing

import Queue from 'bull';

const emailQueue = new Queue('ticket-emails', process.env.REDIS_URL);

export const purchaseTicket = async (req, res) => {
  const ticket = await TicketService.create(req.body);
  await emailQueue.add({ ticketId: ticket.id, userEmail: req.body.email });
  res.status(201).json({ success: true, ticket });
};

emailQueue.process(async (job) => {
  await EmailService.sendConfirmation(job.data);
});

Enter fullscreen mode Exit fullscreen mode

Even if your main server crashes after responding, Bull will re-run the job when it comes back up.

The result

These four patterns transformed iTicket.AZ from a "works on my machine" project into something I'd actually put in front of an interviewer. The concepts map directly to what enterprise teams look for when they say "scalable, resilient, and fault-tolerant."

GitHub: https://github.com/sahin4367/iTicket.AZ