breakscale README

The project's README from github.com/xevrion/breakscale. As one markdown file: README.md.

Breakscale: build a system, load it until it breaks, watch why

Try it | Documentation | Contributing

CI Stars Forks MIT licensed PRs welcome

xevrion/breakscale | Trendshift

The Retry Storm example at 100 requests a second: the database is 99.9% busy while goodput is zero

The Retry Storm example at 100 requests a second. The database is at 99.9% busy and goodput is zero, because retries have tripled 100 offered requests into 348 hitting a database that was already full.

Breakscale is a system design simulator for learning how distributed systems behave under load. You place components on a canvas, wire them together, then drag a slider and watch real queueing behaviour emerge: latency percentiles climbing, queues filling, circuit breakers tripping, whole systems collapsing into retry storms.

Every number comes from an actual discrete-event simulation. Nothing is faked, approximated, or animated to look plausible.

Why this exists

Most system design material is static diagrams and rules of thumb. "Add a cache." "Use a queue." It is hard to build intuition for why p99 latency falls off a cliff as utilisation passes 80 percent, or how a short timeout with retries turns one slow database into a total outage.

Breakscale runs the experiment instead. Load the Retry Storm example, drag the traffic up, and watch goodput fall to zero while the database still runs flat out, because every request that completes has already been abandoned by a caller that gave up.

Getting started

You need Bun.

git clone https://github.com/xevrion/breakscale.git
cd breakscale
bun install
bun dev

Open http://localhost:5173, pick an example from the left, and raise the traffic slider until something goes red.

Features

What is in it

The 23 examples are sixteen teaching scenarios, each isolating one failure mode, plus seven reconstructions of real architectures:

Example What it teaches
Single Server Latency climbs sharply as the database fills up
Load Balanced Three servers share the load, but all still talk to one database
Cache Aside Lower the hit rate and the database takes the whole load
Async Workers The backlog grows when workers fall behind, and drains after
Retry Storm Retries multiply the load that caused them
Rate Limited API Serves slightly less, but what it serves stays fast
Circuit Breaker Break the dependency, watch the circuit trip, then recover
Sharded Database One shard melts while the average still looks healthy
Autoscaling Service Requests fail in the gap while new servers boot

Plus Netflix, Spotify, Discord, Uber, Twitter/X, Stripe and WhatsApp, reconstructed from published engineering material. Each names what it models and what it leaves out. They are teaching diagrams, not insider knowledge.

How the simulation works

The engine in src/sim is a discrete-event simulator. Requests are real objects moving through the topology, and a few details are what make the results worth trusting:

Finite server slots. A component's capacity is how many requests it can work on at once, and instances is how many copies of it are running. Everything beyond instances × capacity waits in a real FIFO queue, and beyond the queue limit it is shed.

Service time variance. Service time is a mean plus a coefficient of variation, sampled from a gamma distribution. Variance is what makes tail latency diverge from the average, so it is modelled rather than assumed away.

Abandoned work still burns capacity. When a caller times out, the downstream keeps working on a request nobody is waiting for. This is why retry storms are visible here rather than theoretical.

Queues acknowledge immediately. A request entering a queue resolves as success at that point and the message is buffered for workers. Backlog depth is real, so you can watch it build and drain.

Percentiles are measured. p50, p95 and p99 come from a ring buffer of completed request latencies, never from multiplying a mean by a constant.

The simulation is deterministic: the same seed and topology replay identically. Correctness is covered by a test suite asserting request conservation, that the failure breakdown sums to the failure total, that utilisation stays within bounds, and that no snapshot field is ever NaN or infinite.

Project layout

src/sim/         the simulation engine. No React, no DOM, no I/O
src/components/  canvas, inspector, metrics, palette
src/content/     glossary text
src/App.tsx      shell: layout, the animation loop, persistence

The engine has no UI dependency, so you can drive it from a script:

import { Engine } from './src/sim/engine';
import { PRESETS } from './src/sim/presets';

const engine = new Engine(PRESETS[0].topology, 42);
for (let i = 0; i < 600; i += 1) engine.advance(1000 / 60);
console.log(engine.snapshot().system);

Contributing

Contributions are welcome, especially new components, new teaching examples, and better explanations. See CONTRIBUTING.md for how the project is put together and what the bar is for a change.

The short version: the numbers have to be true. This is a tool people learn from, so a plausible looking number is worse than no number at all.

Built with

React, TypeScript and Vite, with Lucide for icons. The canvas is hand-rolled SVG and the charts are drawn directly rather than pulled from a charting library, which keeps the bundle small and the rendering predictable.

Star history

Star history for xevrion/breakscale

License

MIT

The bundled Caveat webfont in public/fonts/Caveat/ is not covered by the MIT licence. It is licensed separately under the SIL Open Font License 1.1, which ships alongside the font file as that licence requires. Copyright 2014 The Caveat Project Authors.

breakscale (xevrion/breakscale)

Searching Database…

这是什么?Breakscale 是一个系统设计模拟器:你在画布上摆放组件、把它们连接起来,然后拖动流量滑块,观看真实的离散事件模拟呈现出延迟、排队和故障,从而了解分布式系统在负载下的行为。
这只是动画图示,还是真的在模拟什么?它是一个真正的离散事件模拟引擎,不是视觉把戏。请求被建模为在拓扑结构中移动的真实对象,服务时间服从伽马分布,并给出实测的百分位数。
怎么把它跑起来?用 Bun 和 Vite 在本地运行:打开应用,从左侧面板挑一个示例,然后调高流量滑块,直到有东西出故障为止。
除了 Bun 还需要什么才能运行?只需要 Bun 作为 JS 运行时/包管理器;技术栈是 React、TypeScript 和 Vite,图标使用 Lucide。
它有后端吗?我的数据会被发送到别处吗?没有,一切都完全在浏览器中运行,没有账号、后端或遥测,设计只保存在你自己的电脑上。
它是为谁打造的?它面向学习或教授分布式系统和系统设计的人,他们想要亲手获得的直觉,而不是静态图示和经验法则。
我需要在操作系统上安装什么吗,还是它直接在浏览器里运行?它作为网页应用完全在浏览器中运行;除了本地开发需要 Bun,没有任何操作系统相关的安装。
它会追踪使用情况或向任何地方发送遥测数据吗?不会,没有任何遥测,什么都不会离开你的浏览器。
我可以用哪些组件搭建系统?共有 33 种组件,包括负载均衡器、缓存、数据库、队列、工作进程、CDN、限流器、熔断器、只读副本、分片存储、自动扩缩器、流消息代理、WebSocket 网关、无服务器函数和舱壁隔离。
内置的是哪类示例?23 个完整示例:16 个教学场景,各自隔离一种故障模式(例如重试风暴或熔断器),外加 7 个真实架构的复刻,来自 Netflix、Spotify、Discord、Uber、Twitter/X、Stripe 和 WhatsApp。
我能注入故障来观察系统的反应吗?可以,混沌控制让你能让节点崩溃、变慢、强制错误率或切断单条链路,而且模拟是确定性的,相同的种子和拓扑总会完全一致地重放。
作者为什么要做一个模拟器,而不是更多的图示?静态图示和「加个缓存」之类的经验法则无法建立真正的直觉,比如为什么利用率超过 80% 后 p99 延迟会飙升;Breakscale 会运行真实的实验,让你亲眼看到它发生。
Creator
xevrion
Size
1.9 MB
Stars
1.7K
Updated
CommitSep 29
Age
1mo
Commits · 90 Days