Server Sent Events (SSE) for real-time chat applications on anvil

Hey everyone,

Happy New Year!

Me and a couple of my football friends recently got really tired of browsing content and interacting with fans on reddit, so we decided to build an app where you can watch embedded content from YouTube and keep ourself updated with latest scores, live events and content (from YouTube, Instagram, Reddit etc) related to live events in real-time! We are also building a match thread page where you can view all related content for ongoing football matches in real-time and chat with other fans as well. We tested our app with a couple hundred people, and it looks like the live comment feature is really sticky! However, there’s one huge problem. We are currently using long polling to fetch new comments on each matchthread form – which is really, really bad system design (almost as bad as reddit’s chat functionality!). We’d like to use Server Sent Events (SSE) to update our client from the server as these events (new comments) occur in real-time instead of periodically fetching new comments and hoping our app doesn’t crash upon scaling!

Has someone dealt with Server Sent Events or a similar functionality on anvil before and if yes, how did you implement it??

Thanks a ton in advance!

1 Like

You can use Firebase or Mongo DB or AWS, all which have realtime DBs with listeners you can setup on the client.

Firebase has an anvil integration too:

1 Like

Thanks @duncan_richards12 !

1 Like