[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-116502":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":18,"stars90d":16,"forks30d":16,"starsTrendScore":19,"compositeScore":20,"rankGlobal":10,"rankLanguage":10,"license":21,"archived":22,"fork":22,"defaultBranch":23,"hasWiki":24,"hasPages":22,"topics":25,"createdAt":10,"pushedAt":26,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},116502,"loadsketch","minchenlee\u002Floadsketch","minchenlee","System design simulator: sketch a system, send traffic, see what breaks first.","https:\u002F\u002Floadsketch.mclee.dev",null,"TypeScript",87,17,1,8,0,9,25,35,76.69,"MIT License",false,"main",true,[],"2026-11-18 15:17:54","2026-11-23 18:49:26","# loadsketch\n\n**Sketch a system. Send traffic. See what breaks first.**\n\nloadsketch is a system design simulator. Put components on a canvas, connect them, send traffic, and see what each design decision does: where requests queue, how latency grows, and what breaks first.\n\n**[Try it in your browser →](https:\u002F\u002Floadsketch.mclee.dev)** · [繁體中文](README.zh-TW.md)\n\n![A retry storm in loadsketch: after a traffic spike ends, retries keep the API servers overloaded](docs\u002Fimages\u002Fretry-storm-en.gif)\n\n## What it does\n\n- **Discrete-event simulation.** Every request goes through every component, with queues, timeouts, retries, circuit breakers and failures. Queueing theory values (M\u002FG\u002Fc) are shown next to the simulated results.\n- **Find limit.** Raises steady traffic step by step until the design stops meeting its SLO (`p99 \u003C= 1000 ms`, error rate `\u003C= 1%`), colouring each component on the canvas by busy share and marking what breaks first.\n- **\"Why it happened\".** After every run, the simulator tells the story of the run in time order: overload, retries that multiply the load, failures, recovery or a stuck system.\n- **16 kinds of component, and every parameter can be changed.** Load balancer, API server, cache, database, queue, CDN and more: instances, concurrency, timeouts, retries, circuit breakers, hit rates.\n- **Custom services and presets.** A service that is not in the catalog (search, a payment provider, email) is a custom service: you give its name, icon, service time, capacity, error rate, calls and price per instance. Save any component with its settings as a preset; your presets are in the palette, kept in this browser, and can be exported to a file.\n- **47 examples.** Retry storm, cache stampede, gray failure, split brain, a bad config push, poison messages in a FIFO queue, a region cutover, and more. Each one has a scenario and says what to look at.\n- **On-call practice (8 incidents).** A fault is hidden. You see only the users' error rate and p99, pay points to open a component's metrics, name the component and the kind of fault, then fix the design on the canvas.\n- **Design briefs (6).** Start from requirements and an almost empty canvas: you choose the components and their sizes, then a run shows if the design holds. The brief gives how fast each part is, so a smaller number is not an answer. A reference design is one click away.\n- **Constraint problems (3).** Meet error-rate and p99 targets inside a monthly budget and a complexity limit. Every run shows its cost at sample prices.\n- **Terraform import.** Turn Terraform plan JSON into a design (ECS, Lambda, RDS, Aurora, SQS, ElastiCache, CloudFront and more). The import checks capacity first, and each finding runs as a scenario.\n- **Versions and compare.** Every run keeps a version (the design, the scenario and a summary of the result) in this browser. Pick up to 4 versions to see them side by side: the metrics, and every setting that changed, from what to what. Paired examples open as a comparison with one click, and a share link can carry a comparison.\n- **Edit a design with an AI.** \"Copy a prompt for an AI\" copies a format guide and the current design; paste the answer back. The dialog says in plain words what does not fit the format, lists what changed, and replaces the canvas only after you confirm. The guide is also at [`\u002Fllms-full.txt`](https:\u002F\u002Floadsketch.mclee.dev\u002Fllms-full.txt); [`\u002Fllms.txt`](https:\u002F\u002Floadsketch.mclee.dev\u002Fllms.txt) is a short index of these pages. The site itself does not call any AI model.\n- **Designs are JSON files.** Designs and scenarios (`loadsketch\u002Fdesign@1`, `loadsketch\u002Fscenario@1`) have a JSON Schema in `schema\u002F`. They are easy to read and write for people and AI agents.\n- **A CLI.** The engine does not use the browser, so the CLI and the UI run the same engine.\n- **Share links with no server.** The design and the scenario are compressed into the part of the URL after `#`, which is never sent to a server.\n- **English and Traditional Chinese**, light and dark.\n\nThe examples are simplified models. Some refer to public information about well-known services; they are not the real architecture of any company.\n\n## Screenshots\n\n### Retry storm\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"docs\u002Fimages\u002Fscreenshot-dark.png\">\n  \u003Cimg alt=\"A retry storm in loadsketch: the API servers stay overloaded after the traffic spike ends\" src=\"docs\u002Fimages\u002Fscreenshot-light.png\">\n\u003C\u002Fpicture>\n\n### \"Why it happened\"\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"src\u002Fsite\u002Fmedia\u002Fwhy-en-dark.webp\">\n  \u003Cimg alt=\"After a run, the simulator tells the story of the run in time order\" src=\"src\u002Fsite\u002Fmedia\u002Fwhy-en-light.webp\">\n\u003C\u002Fpicture>\n\n### 47 examples\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"src\u002Fsite\u002Fmedia\u002Fexamples-en-dark.webp\">\n  \u003Cimg alt=\"The list of examples\" src=\"src\u002Fsite\u002Fmedia\u002Fexamples-en-light.webp\">\n\u003C\u002Fpicture>\n\n### On-call practice\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"src\u002Fsite\u002Fmedia\u002Foncall-en-dark.webp\">\n  \u003Cimg alt=\"An on-call incident: only the error rate and p99 are visible\" src=\"src\u002Fsite\u002Fmedia\u002Foncall-en-light.webp\">\n\u003C\u002Fpicture>\n\n### Design briefs\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"src\u002Fsite\u002Fmedia\u002Fbrief-en-dark.webp\">\n  \u003Cimg alt=\"A design brief: requirements, limits and an almost empty canvas\" src=\"src\u002Fsite\u002Fmedia\u002Fbrief-en-light.webp\">\n\u003C\u002Fpicture>\n\n### Constraint problems\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"src\u002Fsite\u002Fmedia\u002Fconstraints-en-dark.webp\">\n  \u003Cimg alt=\"A constraint problem with a monthly budget and a complexity limit\" src=\"src\u002Fsite\u002Fmedia\u002Fconstraints-en-light.webp\">\n\u003C\u002Fpicture>\n\n### Terraform import\n\n\u003Cpicture>\n  \u003Csource media=\"(prefers-color-scheme: dark)\" srcset=\"src\u002Fsite\u002Fmedia\u002Fterraform-en-dark.webp\">\n  \u003Cimg alt=\"A design made from Terraform plan JSON, with capacity findings\" src=\"src\u002Fsite\u002Fmedia\u002Fterraform-en-light.webp\">\n\u003C\u002Fpicture>\n\n## Find the limit\n\nClick **Find limit** in the bottom bar to see how much steady traffic a design holds before breaking:\n\n- **How it searches:** starts at `1 req\u002Fs` and doubles until the first failing step (plus one more step past it to check monotonicity), then bisects `4` times between the last passing rate and the first failing rate. Each step runs a warm-up (at least `30 s`, longer when autoscaled), measures at peak load (at least `120 s`), and stops new traffic to check draining (`120 s`). It keeps the current scenario's settings (read ratio, client timeout, seed) and strips scenario events (spikes, ramps, faults).\n- **What you see on the canvas:** as each step completes, cards are coloured by their average busy share while the load ran (excluding the drain period). When the search ends, the canvas highlights the component that saturated or failed first.\n- **Pass criteria:** front-end `p99 \u003C= 1000 ms`, front-end error rate `\u003C= 1%`, background queue fail rate `\u003C= 0%` (DLQ or expired messages count as failed), and all work drained within `120 s` after traffic stops.\n- **Scaling and known deviations:** high-traffic steps run scaled down (`1\u002Fk` traffic and capacity, targeting ~300,000 requests per run) and multiply counts back, listing any `k > 1` steps under assumptions. Because per-instance slots or instances shrink under scaling, queueing waits near saturation are longer than at full size (making limits conservative), and short cache TTLs read a lower hit ratio. See [docs\u002Faccuracy.md](docs\u002Faccuracy.md) for the measured checks and known deviations.\n\n## How accurate is it?\n\nIt is a model for learning, not a capacity planning tool.\n\n- **What you can trust:** the direction and the mechanism. Which part saturates first, how a slow dependency fills its callers, how retries multiply load, why a system stays down after the spike ends. A comparison of two designs under the same scenario is worth more than one number.\n- **What is checked:** single stations are tested against queueing theory. For M\u002FM\u002F1 the mean latency is within 5% and the p99 within 10%; M\u002FM\u002F4 and M\u002FD\u002F1 waits are within 10% (`tests\u002Fqueueing.test.ts`). The broader accuracy suite ([docs\u002Faccuracy.md](docs\u002Faccuracy.md), `tests\u002Faccuracy.test.ts`) covers 25 checks across queueing, bounded rejection, two-stage series, retries, load balancing, scaling and timeouts: 24 pass within tolerance and 1 is documented as a known deviation. Every run is deterministic for a seed, and two designs see the same traffic.\n- **What it leaves out:** packets and bandwidth, memory and CPU cores, the contents of the data (it counts stale reads and lost writes, but cannot tell you if your data is correct), and the specific behaviour of real products. A \"database\" here is a generic database, not PostgreSQL.\n- **Do not** size a production system from an absolute number in a run. Measure the real system.\n\nThe assumptions are written down in [docs\u002Fmodel.en.md](docs\u002Fmodel.en.md) (summary) and [docs\u002Fmodel.md](docs\u002Fmodel.md) (full, Chinese). If a run does not agree with a real system, a formula or a paper, please [open an issue](https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch\u002Fissues\u002Fnew?template=sim-vs-real.yml). I do not know how far the model is from production systems, and reports are how it gets better.\n\n## Run it locally\n\nRequirements: Node.js 22.18 or later.\n\n```sh\ngit clone https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch.git\ncd loadsketch\nnpm install\nnpm run dev        # the simulator: http:\u002F\u002F127.0.0.1:5317\u002Fapp\u002F   the intro site: http:\u002F\u002F127.0.0.1:5317\u002F\n```\n\n## CLI\n\n```sh\nnode cli\u002Floadsketch.ts run examples\u002Fdesigns\u002Fthree-tier.json --scenario examples\u002Fscenarios\u002Fspike.json --lang en\nnode cli\u002Floadsketch.ts run examples\u002Fdesigns\u002Fthree-tier.json --rps 2000 --json     # the result as JSON\nnode cli\u002Floadsketch.ts validate examples\u002Fdesigns\u002F*.json\nnode cli\u002Floadsketch.ts fmt examples\u002Fdesigns\u002Fthree-tier.json --check\nnode cli\u002Floadsketch.ts import terraform tests\u002Fimport\u002Ffixtures\u002Fecs-rds.plan.json --out design.json\n```\n\nThe CLI prints Chinese by default; use `--lang en` or `LOADSKETCH_LANG=en` for English.\n\n## Using the simulator\n\n- Drag a component from the left onto the canvas. Drag from the point on the right of a card to the left of another card to connect them.\n- Click a component or a connection to change its parameters on the right.\n- Pick a scenario and a speed at the bottom, then press **Run**. The dots on a connection are requests: blue is a read, orange is a write, red is a failure. At 1× speed or slower you see single requests.\n- **Skip to end** computes the whole run at once.\n- To keep a component with its settings, select it and press **Save as preset** at the top of the right panel. It appears under **My presets** in the palette.\n- **Versions** (right panel) lists your runs. To change a design with an AI, use **Paste design JSON** in the file menu.\n- Panels: `⌘B` left, `⌥⌘B` right, `⌘J` bottom (Ctrl on Windows and Linux).\n- URL options: `?example=three-tier&scenario=spike&speed=0.1&autorun=1&theme=dark&lang=en`.\n\n## Use it from an AI agent\n\nloadsketch has an Agent Skill for agents such as Claude Code. Download [the zip](https:\u002F\u002Floadsketch.mclee.dev\u002Fskills\u002Floadsketch.zip) from **Paste design JSON** in the file menu (**Download the skill (zip)**), or from the link, and unpack it into `~\u002F.claude\u002Fskills\u002F`: it adds a `loadsketch` folder with two files. [`SKILL.md`](https:\u002F\u002Floadsketch.mclee.dev\u002Fskills\u002Floadsketch\u002FSKILL.md) holds the steps, the rules, the fields and one line per component; [`reference.md`](https:\u002F\u002Floadsketch.mclee.dev\u002Fskills\u002Floadsketch\u002Freference.md) holds the parameters of each component, one section each, and the agent reads only the section it needs. Then ask the agent to change a design: give it the design JSON (**Copy only the design JSON**), and paste its answer back with **Paste design JSON**. `npm run ai-guide` makes these files, `\u002Fllms.txt` and `\u002Fllms-full.txt` from the component catalog.\n\n## Tests\n\n```sh\nnpm run test:quick     # about 10 s: fast unit tests and the i18n check\nnpm run test:slow      # slow unit tests, including the golden test\nnpm run e2e            # UI tests in headless Chromium\nnpm run build          # type check, then bundle to dist\u002F\n```\n\n## Project layout\n\n| Path | What it holds |\n|---|---|\n| `src\u002Fschema\u002F` | The file formats (zod), the component kinds, the design checks |\n| `src\u002Fengine\u002F` | The discrete-event simulation. No browser APIs |\n| `src\u002Flearn\u002F` | Lessons, on-call incidents, design briefs, constraint problems, cost, diagnosis |\n| `src\u002Fimport\u002Fterraform\u002F` | Terraform plan JSON → design |\n| `src\u002Fapp\u002F` | The simulator UI (React, React Flow). The simulation runs in a Web Worker |\n| `src\u002Fsite\u002F` | The intro site. Its live panels are the simulator in an iframe (`?embed=1`) |\n| `cli\u002F` | The command line |\n| `examples\u002F` | Designs and scenarios (JSON) |\n| `docs\u002Fmodel.md` | How the model works and what it assumes (Chinese) |\n| `docs\u002Fmodel.en.md` | The same, as an English summary |\n| `docs\u002Fdesign-system.md` | The look and motion rules of the UI (Chinese) |\n\n`AGENTS.md` has the rules for changing the code, for people and for coding agents.\n\n## Design\n\nThe UI follows [kumo](https:\u002F\u002Fgithub.com\u002Fcloudflare\u002Fkumo), Cloudflare's open-source design system (MIT). The colour tokens and the look of the cards, buttons, inputs, badges and menus come from kumo; the components are written in this repository and do not use the kumo package. The mapping is at the top of `src\u002Fapp\u002Findex.css`, and the rules are in [docs\u002Fdesign-system.md](docs\u002Fdesign-system.md).\n\nThe site runs on Cloudflare Workers static assets (`npm run deploy`).\n\n## Contributing\n\n### Where help matters most\n\nEach of these issues describes one direction:\n\n- [#4 Turn real incidents into examples](https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch\u002Fissues\u002F4)\n- [#5 A new learning path: caches, queues, or your topic](https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch\u002Fissues\u002F5)\n- [#6 Check one class of model behaviour against theory or measurements](https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch\u002Fissues\u002F6)\n- [#7 A new kind of component](https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch\u002Fissues\u002F7)\n- [#8 English is the source text](https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch\u002Fissues\u002F8)\n- [#9 Importer: cover the AWS services your stack uses](https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch\u002Fissues\u002F9)\n- [#10 Tell us where the simulation does not match reality (no code)](https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch\u002Fissues\u002F10)\n\nAll open issues that need help: [`help wanted`](https:\u002F\u002Fgithub.com\u002Fminchenlee\u002Floadsketch\u002Fissues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22).\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md).\n\n## License\n\n[MIT](LICENSE)\n","loadsketch 是一个面向系统设计工程师的交互式仿真工具，用于在部署前可视化评估分布式系统架构的可靠性与性能边界。它支持在画布上拖拽构建含负载均衡器、API服务、缓存、数据库等16类组件的拓扑，通过离散事件模拟真实请求流，实时呈现队列堆积、延迟增长、重试风暴、熔断触发等现象，并自动探测SLO（如p99≤1000ms、错误率≤1%）失效点及根本原因。内置47个典型故障案例、On-call演练、设计简报与成本约束问题，支持Terraform配置导入和多版本对比，适用于系统设计教学、架构评审预演和SRE能力训练。",2,"2026-11-24 04:53:42","CREATED_QUERY"]