npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yurtzy/backend-design-patterns

v1.0.1

Published

High-performance Distributed System Patterns (Consistent Hashing, Token Bucket, LSM Tree) with zero dependencies.

Downloads

60

Readme

Backend Design Patterns

License: ISC TypeScript Build Status

Production-grade, zero-dependency implementations of core distributed system patterns in TypeScript.

Designed for engineers who need clean, reference implementations without the bloat of heavy frameworks.

Patterns

Consistent Hashing

A ring-based consistent hashing implementation with virtual nodes.

  • Complexity: O(log N) lookup.
  • Use Case: Sharding data across distributed caches or databases.

Token Bucket Rate Limiter

High-performance lazy-refill token bucket.

  • Features: Burst support, thread-safe logic (for Node.js event loop).
  • Use Case: API rate limiting, traffic shaping.

Circuit Breaker

Robust state machine for fault tolerance.

  • States: CLOSED -> OPEN -> HALF_OPEN
  • Use Case: preventing cascading failures in microservices.

Bloom Filter

Probabilistic data structure for space-efficient set membership.

  • Complexity: O(k) for add/check (k = hash count).
  • Use Case: Caches (filtering non-existent keys), Web Crawlers (visited URLs).

LSM Tree

Log-Structured Merge Tree basics (MemTable + SSTable).

  • Complexity: O(log N) write, O(read_amplification) read.
  • Use Case: Write-heavy databases (Cassandra, RocksDB).

System Design Guide

We included a cheat sheet for choosing the right pattern in interviews.

Installation

npm install backend-design-patterns

Try it Live

Want to see these patterns in action? We included a simulated server environment.

npm run demo

Simulates a Load Balancer + Rate Limiter + Circuit Breaker handling traffic.

Usage

Consistent Hashing

import { ConsistentHashing } from 'backend-design-patterns/consistent-hashing'

const ch = new ConsistentHashing()
ch.addNode('redis-1')
ch.addNode('redis-2')

const node = ch.getNode('user-session-123')
console.log(`Assign to: ${node}`)

Rate Limiter

import { TokenBucket } from 'backend-design-patterns/rate-limiter'

const limiter = new TokenBucket(100, 10) // 100 capacity, 10 tokens/sec
if (limiter.tryConsume(1)) {
  // Handle request
} else {
  // 429 Too Many Requests
}
  // 429 Too Many Requests
}

Bloom Filter

import { BloomFilter } from 'backend-design-patterns/bloom-filter'

const filer = new BloomFilter(1024, 3)
filter.add('superuser')

if (filter.mightContain('superuser')) {
  // It MIGHT be in the set
}

Benchmarks

Core patterns are optimized for high-throughput environments.

| Pattern | Operation | Ops/Sec (approx) | |---------|-----------|------------------| | Token Bucket | tryConsume | 25,000,000+ | | Consistent Hashing | getNode | 3,000,000+ | | Bloom Filter | mightContain | 15,000,000+ | | LSM Tree | put (MemTable) | 500,000+ |

Measured on standard i7 equivalent hardware using npm run benchmark.

Development

This project uses TypeScript and Vitest.

npm install
npm test

Contributing

We welcome contributions! Please keep implementations minimal and zero-dependency. See CONTRIBUTING.md for details.


Simple. Robust. TypeScript.