# How Shreeng Engine Serves 1,563 RPS on a Single Mumbai VPS

> Inside Shreeng Engine architecture: dual Redis isolation (noeviction vs allkeys-lru), PostgreSQL L3 deterministic cache recovery, isolated Reverse worker, and native sweph.

- Canonical HTML: https://shreeng.com/blog/1563-rps-swiss-ephemeris-astrology-api
- Category: Engineering
- Last Verified: 2026-11-30
- API Docs: https://docs.shreeng.com

Many astrology APIs slow down or return HTTP `504` timeouts under burst load because ephemeris calculations, database queries, and long-running birth-time searches share one thread and one cache pool.

**Shreeng Engine** achieves **1,563.7 RPS** on cached Panchang and **606.3 RPS** on 100% uncached D1 Kundli charts on a single `4 vCPU / 5.8 GiB` HostDzire Mumbai VPS — with **0 5xx errors**.

## Measured Origin Benchmarks (`2026-11-30`)

| Suite                                          | Peak / Sustained RPS | Latency (`p50` / `p99`) | Concurrency |
| ---------------------------------------------- | -------------------- | ----------------------- | ----------- |
| **Cached Panchang (`panchang-hot-repeat`)**    | **1,563.7 RPS**      | `103 ms` `p50`          | `c=200`     |
| **Geocode LRU (`light-geocode`)**              | **1,456.8 RPS**      | `108 ms` `p50`          | `c=200`     |
| **Uncached D1 Chart (`chart-d1`)**             | **606.3 RPS**        | `173 ms` `p50`          | `c=120`     |
| **Ashtakoota Matching (`matching-ashtakoot`)** | **425.88 RPS**       | `64 ms / 200 ms`        | `c=30`      |
| **Mixed Storm vs 6×15y Reverse Jobs**          | **148.92 RPS**       | `171 ms / 642 ms`       | `c=30`      |
| **Shadbala (`strength-shadbala`)**             | **15.63 RPS**        | `1712 ms / 3005 ms`     | `c=30`      |

## Three Architectural Choices That Made the Difference

1. **Dual-Redis Memory Isolation:** Rate-limit windows, concurrency semaphores, and BullMQ jobs sit in `redis-queue` (`noeviction`), completely separated from LRU API response caching in `redis-cache` (`allkeys-lru`).
2. **Cluster HTTP Workers + Isolated Reverse Worker:** `API_WORKERS=auto` runs dedicated HTTP workers alongside an isolated background worker (`768 MB` heap cap) so CPU-heavy 15–30 year Reverse scans never starve live REST traffic.
3. **Revision-Aware 3-Layer Deterministic Cache:** Responses key off canonical `endpoint + tzdb/logic revision + sha256(normalized-input)`. Even after restarting with an empty Redis cache, PostgreSQL L3 recovers cached 1-year festival tables in `521 ms` without re-computing `sweph`.

```bash
curl -s "https://api.shreeng.com/v2/chart?locationId=1276300&datetime=1993-03-12T05:30:00" \
  -H "x-api-key: $SHREENG_API_KEY"
```

## Frequently Asked Questions

### Why does Shreeng run two separate Redis instances?
redis-queue uses noeviction so BullMQ jobs, throttler counters, concurrency semaphores, and portal JWT sessions are never evicted; redis-cache uses allkeys-lru exclusively for deterministic API response caching.

### Do long Reverse astrology searches degrade live D1 chart API latency?
No. Reverse jobs execute in an isolated background worker process; live mixed traffic held 148.92 RPS with 0 HTTP 5xx errors during 6 concurrent 15-year Reverse jobs.
