Rails 7 E110 Realtime Online User Tracking with Actioncable, Kredis, Turbo Broadcasts

10/02/2023 (over 1 year ago)
websockets actioncable hotwire hotwire turbo live updates live counter track users online redis kredis

This episode was inspired by the great work of other creators. Hopefully my input tackles some flaws that would appear in a production environment, demistifies some code and potential challanges.

Zero lines of javascript.
Don't store view login in models.
Don't hit the relational database on every web action.

Do you think this can be improved even more? Let me know what you think 🙏.

Episode source code: https://github.com/corsego/110-live-users-count/commit/238ab48dd8871b20c30387fd1c64d362992560d8
Based on this blogpost: https://blog.corsego.com/action-cable-broadcast-users-online
Timestamps approach to see users online: https://blog.corsego.com/set-user-status-online

0:00 Other approaches to tracking users online
2:41 Demo of the final application
4:22 Track online users with Kredis, Hotwire Turbo Stream Broadcasts and Action Cable
21:15 Not logged in users can see users online
23:32 Summary


0
Sign in to join the conversation