Skip to content

Convert Monolith to Microservices Architecture#3

Merged
bit-web24 merged 32 commits into
masterfrom
dist_sys
Jun 15, 2026
Merged

Convert Monolith to Microservices Architecture#3
bit-web24 merged 32 commits into
masterfrom
dist_sys

Conversation

@bit-web24

Copy link
Copy Markdown
Owner

Feature Release: Distributed Systems Architecture & URL Expiry

This merge introduces a massive architectural overhaul of the Bittuly platform, migrating the core systems to a high-performance, event-driven, distributed microservices architecture capable of handling viral scale.

🚀 Key Architectural Upgrades

1. Messaging, Resilience & Event-Driven Metrics (RabbitMQ)

  • Decoupled Analytics: Link redirects no longer wait for synchronous database updates. Click tracking is now published asynchronously to RabbitMQ (click_events_queue), resulting in sub-millisecond redirection times.
  • Dedicated Consumer Service: Built a brand new Rust-based consumer-service to ingest background tasks.
  • Fault Tolerance: Implemented a robust "At-Least-Once" delivery system featuring Dead Letter Queues (DLQ) and mathematical exponential backoff retry mechanisms (3s -> 9s -> 27s) for failing jobs.

2. High-Concurrency & Cache Stampede Protection

  • Singleflight Request Coalescing: Implemented a state-of-the-art L1 micro-cache using moka in the Rust backend. This guarantees that if a viral link generates a 200,000 req/sec spike, identical concurrent requests are coalesced in memory—ensuring the database receives exactly 1 query, completely eliminating Cache Stampedes / Thundering Herd failures.
  • Gateway Scaling: Re-configured NGINX to handle up to 200,000 global concurrent connections (worker_rlimit_nofile), while maintaining strict IP-based rate limiting (20r/s per user) to protect against DDoS attacks.

3. URL Expiration Lifecycle (Phase 3)

  • Precision Tracking: Added accurate microsecond expiration tracking (TIMESTAMPTZ) natively into PostgreSQL.
  • Dynamic Redis Eviction: The caching layer calculates exact chronological TTLs, forcing Redis to automatically evict links from memory the exact millisecond they expire.
  • Dead Link Resurrection: Developed a sophisticated Upsert model that gracefully allows users to re-shorten and reactivate exact URLs if their previous shortcode has naturally expired.

🎨 Frontend & UX Enhancements

  • Seamless Error Interception: NGINX now intelligently intercepts backend 410 Gone and 404 Not Found errors, proxying them to the React Router to render the <Unavailable /> page beautifully without altering the user's URL bar.
  • Modern UI Dialogs: Added explicit Confirmation Modals for safe deletion and rich "Link Details" panels.
  • Expiration Controls: Integrated Date/Time pickers for precise TTL configuration on link creation, paired with visual Active/Expired UI status badges on the dashboard.

bit-web24 added 30 commits June 13, 2026 16:33
…koff

- Added 3 tiered delay queues (3s, 9s, 27s) for user deletion retries via TTL and DLX.

- Added permanent dead letter queue (DLQ) for failed events exceeding 3 retries.

- Added dynamic local async sleep backoff for high-throughput click batches.
…ions

Details:

- Add moka crate to url-service for L1 micro-caching

- Wrap Redis and Postgres lookups in singleflight get_with to prevent Cache Stampedes / Thundering Herd under high concurrent load

- Increase NGINX worker_connections and worker_rlimit_nofile to support up to 200,000 global concurrent connections
@bit-web24
bit-web24 merged commit bd15c12 into master Jun 15, 2026
2 checks passed
@bit-web24
bit-web24 deleted the dist_sys branch June 21, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant