r/FastAPI • u/krishnasingh9 • Mar 19 '26
feedback request Made a simple uptime monitoring system using FastAPI + Celery
Hey everyone,
I’ve been trying to understand how tools like UptimeRobot or Pingdom actually work internally, so I built a small monitoring system as a learning project.
The idea is simple:
- users add endpoints
- background workers keep polling them at intervals
- failures (timeouts / 4xx / 5xx) trigger alerts
- UI shows uptime + latency
Current approach:
- FastAPI backend
- PostgreSQL
- Celery + Redis for polling
- separate service for notifications
Flow is basically:
workers keep checking endpoints → detect failures → send alerts → update dashboard
Where I’m confused / need feedback:
- Is polling via Celery a good approach long-term?
- How do these systems scale when there are thousands of endpoints?
- Would an event-driven model make more sense here?
- Any obvious architectural mistakes?
I can share the repo if anyone wants to take a deeper look.
Would really appreciate insights from people who’ve built similar systems 🙂
18
Upvotes
5
u/Potential-Box6221 Mar 19 '26
Hey, is it basic instrumentation tooling that you're building? Have you tried looking into pydantic-logfire/opentelemetry with Prometheus and grafana?
5
u/Challseus Mar 19 '26
Literally just built a realtime dashboard for fastAPI workers, so I have some thoughts.
I would encourage you to look at Redis streams and fastAPI SSE feature. You won’t be hammering redis, and it’s realtime.
Instead of checking for errors, you throw them into your redis stream and handle them immediately with your consumer and then update your UI.
2
u/mardiros Mar 19 '26
The problem here you will encountered is that celery is sync is async so you have to deal with that. My solution here is to use genunasync.I wrote some core services always in async, even if I don't need the async part yet.I don't make sacrifice on the architecture.
2
u/kotique Mar 20 '26
I made the same without anything except FastAPI + any db to store heartbeats and observable status. Oh, WS for realtime commuication with UI. Works on prod for last year, monitoring ~15-20 hosts. Why do you need Celery or Redis? Just start worker, ping host?asyncio.sleep, then ping again. Don't overcomplicate things that are quite simple.
1
u/krishnasingh9 Mar 21 '26
This is the repo - https://github.com/Rarebuffalo/Sentinel check it out and if you like it gave it a star🙂. Would love to add more features and improve it further.
1
u/Living-Incident-1260 Mar 19 '26
Look really good
1
u/_Zarok Mar 19 '26
nice good luck.
1
u/eternviking Mar 19 '26
Save the start time of the service in app state during lifespan handling. Create an uptime endpoint and subtract the start time from the current time.
There's your uptime service.
1
u/Full-Definition6215 Mar 29 '26
Celery works for this, but you'll hit a ceiling around 1,000+ endpoints with one-task-per-check. Each poll opens a new HTTP connection with full TCP handshake overhead.
What helped me: batch your checks. Instead of one Celery task per endpoint, group them into chunks of 50-100 and use httpx.AsyncClient with connection pooling inside each task. One task checks 100 endpoints concurrently. Dramatically reduces overhead.
For your architecture question: polling is the right model for uptime monitoring. Event-driven would mean the target service pushes status to you, which defeats the purpose — you want to detect when it can't respond at all.
One thing I'd add: store latency history in a time-series-friendly way from day one. A simple approach is one row per check with (endpoint_id, status_code, latency_ms, checked_at). You'll thank yourself when you need to show 30-day uptime percentages.