-
Notifications
You must be signed in to change notification settings - Fork 2
Backend Services and Event Processing
GiZano edited this page Aug 5, 2026
·
1 revision
- Rate Limiting: Protects against DoS via a sliding-window rate limiter in Redis (50 req/s per IP).
-
Queue Offloading: Validated payloads are non-blockingly serialized and pushed to a Redis List (
seismic_events), returning a202 Acceptedimmediately.
A decoupled Python worker (worker.py) consumes the seismic_events queue via a blocking brpop.
- Shares a highly optimized SQLAlchemy connection pool targeting PostgreSQL/PostGIS.
- Evaluates the alarm logic within a single, atomic database transaction (
db.commit()).
The worker estimates physical magnitude based on a MyShake-style MEMS calibration approach:
Where K_CALIBRATION = 1.6), and B_OFFSET = 3.0).
-
Thresholding: Triggers an
Alertif the magnitude reaches or exceeds 4.5. -
Redis Deduplication: Uses an atomic check-and-set (
SET nx=True, ex=60) keyed byzone_idto enforce a 60-second cooldown per zone, preventing notification spam during a swarm. -
Outbox Pattern: Publishes the JSON payload to the
quake_alertsRedis Pub/Sub channel. - AI Enqueue: When enabled, confirmed alerts additionally enqueue context to the AI Emergency Report Service.
- Previous: Data Plane & Message Broker (MQTT)
- Next: Mobile Client & Live Telemetry
- Back to: Home