0

I am planning to create an application for realtime scoreboard and stats. User does the scoring and it has to be broadcasted to other users in realtime. I am currently using postgreSQL as my backend database.

User --> Feeds Score --> Updates DB --> Another User gets score updates in realtime.

Should I use some middleware to broadcast my scores in realtime to the users who are watching the scores online?

Giri
  • 451
  • 1
  • 4
  • 13
  • Your post will likely get closed because you are soliciting opinions rather than asking a specific question about an issue you are having. But the answer is Yes, PubNub will allow you to easily broadcast the stat updates with or without Postgres. There are best practices you can follow but int he end, just publish the stat updates to a channel through PubNub and all listening clients will be updated in realtime. – Craig Conover Jun 01 '21 at 22:54

1 Answers1

0

PubNub Publish on DB Commit

Here's a high-level design:

  1. Send stat update to your server
  2. Your server inserts stat into your DB
  3. Your DB confirms insert was successful
  4. Your server publishes stat update to a PubNub channel
  5. Clients subscribed to that channel receive stat update
  6. Client app updates UI to display the stat update

Here's an old PubNub KB article (Can I publish a message via database trigger?) that addresses using a database trigger but also suggests using proper two-phase DB commit.

Craig Conover
  • 4,710
  • 34
  • 59