My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Designing chat application - Send message to other connected client (Rust backend)

John D.'s photo
John D.
·Mar 11, 2020

To practice my Rust skills I want to build a chat application. Before doing so, I searched google on "chat application rust github" and I get a few examples, but they are all not maintained. I am not sure how to send messages between clients that are currently connected to my server.

All chatters are connected through a websocket (github.com/housleyjk/ws-rs). I am already using redis (github.com/mitsuhiko/redis-rs) for caching geo locations, so maybe a pub/sub could work? I could also add all my connected persons into a hashmap or something and than do a lookup, but I doubt that is a scalable solution. I see that Actix also have chat examples out there, but before learning and exploring another crate, I want to make sure it fits my needs:

  • can handle lots of users without exploding RAM
  • does not create a connection to some database for each and every user (I think that is what redis is doing in the rust crate for creating a pub/sub connection)
  • should be decent fast (it does not have to be blazing fast, but please no locking on every message send on e.g. a hashmap of users)
  • abstractions like rabbitMQ are ok, I like to learn if it can do what I want -it would be nice to be able to send a message to multiple users (group messaging)

Does anyone has experience with the same requirements?