# Taka

> Taka: 2 services, 18 components and 26 connections on 3 hosts — takabachan-social and takabachan-ecommerce.

A multi-service system design shared from System Canvas, a tool for designing distributed systems and simulating how they behave under load.

- Interactive version: https://vuteem.com/tools/sys-canvas/projects/share/TqVB4C8av1
- 18 components, 26 connections, 2 services
- How the simulation models each component: https://vuteem.com/tools/sys-canvas/docs

## Overview — Components

- **takabachan-social** (Microservice) — in VPC "Takabachan VPC"
- **takabachan-ecommerce** (Microservice) — in VPC "Takabachan VPC"
- **User / Client**: Requests Per Second: 10000 req/s; Protocol: HTTPS
- **Cloudflare Worker** (API Gateway): Protocol: HTTPS; Rate Limit (req/s): 0 req/s
- **Cloudflare CDN** (CDN): TTL: 3600 s; Cache Hit Rate: 0.8
- **Meilisearch** (Elasticsearch) — in VPC "Takabachan VPC", on host "VPS": Cluster Nodes: 1; RAM per Node: 8,192 MB; Request Absorption Rate: 1
- **NATs Stream** (Message Queue) — in VPC "Takabachan VPC", on host "VPS": Queue Type: Standard; Visibility Timeout: 30 s; Request Absorption Rate: 1
- **Valkey** (In-Memory Cache) — in VPC "Takabachan VPC", on host "VPS": Memory: 4,096 MB; Max Connections: 10000; Cache Hit Rate: 0.9; Request Absorption Rate: 1; Enable Sharding: off
- **Worker: Image/Video** (Service Worker) — in VPC "Takabachan VPC", on host "VPS": Worker Threads: 4 workers; Avg Job Duration: 100 ms; Max Queue Depth: 500; Retry on Failure: off; Memory / Worker: 64 MB; CPU-Bound Share of a Job: 0.5; Request Absorption Rate: 1
- **R2** (Object Storage): Throughput (MB/s): 100 MB/s; Storage Class: Standard; Presigned URLs: off; Prefix Shards: 1; Encryption: None; Transfer Acceleration: off; Request Absorption Rate: 1
- **Mail Server**: Daily Send Limit: 50000; Concurrent Conns: 50; Protocol: SMTP; Request Absorption Rate: 1

## Overview — Connections

- User / Client → Cloudflare CDN (HTTPS, cache path)
- Cloudflare CDN → Cloudflare Worker (HTTPS)
- Cloudflare Worker → takabachan-ecommerce (HTTP)
- Cloudflare Worker → Meilisearch (TCP, cache path)
- Cloudflare Worker → takabachan-social (HTTP)
- takabachan-social → Valkey (TCP, cache path)
- takabachan-social → NATs Stream (TCP)
- NATs Stream → takabachan-ecommerce (TCP)
- NATs Stream → takabachan-social (TCP)
- Meilisearch → takabachan-ecommerce (HTTP)
- Meilisearch → takabachan-social (HTTP)
- takabachan-ecommerce → NATs Stream (TCP)
- takabachan-ecommerce → Valkey (TCP, cache path)
- takabachan-ecommerce → Worker: Image/Video (HTTPS)
- takabachan-social → Worker: Image/Video (HTTPS)
- Worker: Image/Video → R2 (HTTPS)
- Worker: Image/Video → Mail Server (HTTPS)
- Cloudflare Worker → Valkey (HTTPS)

## Overview — Hosts and clusters (components inside share their CPU, RAM and network)

- **VPS**: 10 vCPU, 16,384 MB RAM, 1000 Mbps — runs Meilisearch, NATs Stream, Valkey, Worker: Image/Video

## Overview — VPCs (private networks)

- **Takabachan VPC** (us-east-1, 10.0.0.0/16) — contains takabachan-social, takabachan-ecommerce, Meilisearch, NATs Stream, Valkey, Worker: Image/Video

## Service: takabachan-social

### Components

- **SQL Database** — on host "VPS": RAM: 4,096 MB; Max Connections: 100; IOPS: 500; Partitioning: None; Enable Sharding: off; Request Absorption Rate: 1
- **Server / VM** — on host "VPS": RAM: 2,048 MB; CPU Cores: 2; Max Connections: 1000; Request Absorption Rate: 1
- **Service Worker** — on host "VPS": Worker Threads: 4 workers; Avg Job Duration: 100 ms; Max Queue Depth: 500; Retry on Failure: off; Memory / Worker: 64 MB; CPU-Bound Share of a Job: 0.5; Request Absorption Rate: 1
- **Traefik** (Container) — on host "VPS": CPU Limit (cores): 0.5 cores; Memory Limit: 512 MB; CPU Request (cores): 0.5 cores; Memory Request: 512 MB; Min Replicas: 1; Max Replicas: 1; Scale On: CPU utilization (HPA, target tracking); Target CPU: 70 % of request; Request Absorption Rate: 1
- **R2** (Object Storage): Throughput (MB/s): 100 MB/s; Storage Class: Standard; Presigned URLs: off; Prefix Shards: 1; Encryption: None; Transfer Acceleration: off; Request Absorption Rate: 1

### Connections

- Server / VM → SQL Database (TCP)
- Server / VM → Service Worker (TCP)
- Traefik → Server / VM (HTTP)
- SQL Database → R2 (HTTPS)

### Hosts and clusters (components inside share their CPU, RAM and network)

- **VPS**: 6 vCPU, 8,192 MB RAM, 1000 Mbps — runs SQL Database, Server / VM, Service Worker, Traefik

## Service: takabachan-ecommerce

### Components

- **Server / VM** — on host "VPS": RAM: 2,048 MB; CPU Cores: 2; Max Connections: 1000; Request Absorption Rate: 1
- **SQL Database** — on host "VPS": RAM: 4,096 MB; Max Connections: 100; IOPS: 500; Partitioning: None; Enable Sharding: off; Request Absorption Rate: 1
- **Service Worker** — on host "VPS": Worker Threads: 4 workers; Avg Job Duration: 100 ms; Max Queue Depth: 500; Retry on Failure: off; Memory / Worker: 64 MB; CPU-Bound Share of a Job: 0.5; Request Absorption Rate: 1
- **Traefik** (Container) — on host "VPS": CPU Limit (cores): 0.5 cores; Memory Limit: 512 MB; CPU Request (cores): 0.5 cores; Memory Request: 512 MB; Min Replicas: 1; Max Replicas: 1; Scale On: CPU utilization (HPA, target tracking); Target CPU: 70 % of request; Request Absorption Rate: 1
- **R2** (Object Storage): Throughput (MB/s): 100 MB/s; Storage Class: Standard; Presigned URLs: off; Prefix Shards: 1; Encryption: None; Transfer Acceleration: off; Request Absorption Rate: 1

### Connections

- Server / VM → SQL Database (TCP)
- Server / VM → Service Worker (TCP)
- Traefik → Server / VM (HTTP)
- SQL Database → R2 (HTTPS)

### Hosts and clusters (components inside share their CPU, RAM and network)

- **VPS**: 6 vCPU, 8,192 MB RAM, 1000 Mbps — runs Server / VM, SQL Database, Service Worker, Traefik
