Skip to main content

Analytics Service — Deployment Topology

Status: populated Owner: SRE Last updated: 2026-04-18

1. Runtime

  • Node.js 22 LTS, TypeScript 5.x strict.
  • NestJS 10 + @nestjs/platform-fastify.
  • Image: distroless Node, multi-stage build, non-root.
  • Listen ports: 3030 HTTP, 9464 metrics.

2. Kubernetes

ObjectValue
KindDeployment
Replicas2 (min) / HPA 2–8
HPA triggersCPU 70%; custom metric anlyt_nats_consumer_pending (target 5,000 per pod)
Rolling updatemaxSurge=1, maxUnavailable=0
PDBminAvailable=1
Resourcesrequests: 500m CPU / 512Mi; limits: 2 CPU / 1Gi
ServiceAccountanalytics-service

3. Dependencies (at runtime)

DepModeNotes
PostgreSQLPrimary writer + read replicasRead-heavy; separate read replica for REST API queries
NATS JetStream3-node cluster2 durable consumers (anlyt-billing-consumer, anlyt-dlr-consumer)
ClickHouse (optional)ETL onlyNot in real-time path

4. No Kong Route

This service has no Kong route. Kubernetes Service is of type ClusterIP. External traffic cannot reach it without going through admin-dashboard or customer-portal (which are Kong-fronted).

5. Read Replica Usage

  • NATS consumer processing writes go to PG primary.
  • REST API queries go to PG read replica (connection pool configured by DATABASE_READ_URL).
  • This separation prevents dashboard query load from blocking event processing.

6. Scheduled Jobs

JobScheduleDescription
anlyt-daily-rollup0 * * * * (hourly)Rolls hourly buckets into daily
anlyt-processed-purge0 2 * * * (daily 02:00 UTC)Purges processed_events older than 48 h
anlyt-clickhouse-etl0 3 * * * (daily 03:00 UTC, optional)Copies rows > 90 d to ClickHouse

Jobs run as Kubernetes CronJob objects using the same image as the main Deployment.

7. Regions

Single-region deployment matches PostgreSQL primary region. ClickHouse can be cross-region if needed for BI.