r/FastAPI • • Sep 26 '25

Question Realtime Sockets Scalability

Hi everyone,

I need to build real-time functionality for a chat application and I use postgresql+fastapi. My current approach to support real-time features would be a LISTEN/NOTIFY trigger in my db and a fastapi connection pooler since postgres limits direct DB connections to ~500. So each fastapi instance would support X websocket connections and manage them. Have you build anything similar that supports over 1k concurrent users? How scalable is this?

10 Upvotes

13 comments sorted by

View all comments

Show parent comment

3

u/Emergency_Bet_7192 Sep 26 '25

It depends on more than just concurrent users. How many requests/s? What is happening in most of the requests? Do events fanout to multiple users (eg group chats)? What kind of delivery guarantees do you need? Listen/notify is ephemeral, what if a clients internet is unstable? Generally speaking, listen/notify is not built for scale, and for delivery orders/guarantees alone I would look into brokers

1

u/felword Sep 26 '25

Thanks for your reply, thats very helpful! I'm deploying on gcp, is there any setup you would recommend for brokers that is easy&cheap to build?