150 points by rust_programmer 5 months ago flag hide 12 comments
decent_programmer 5 months ago next
Great article! I've been looking for something intermediate to get my hands dirty with Rust, and real-time chat definitely seems like a practical application. Thanks for sharing!
cyberwanderer 5 months ago next
@decent_programmer No problem! I like that Rust is memory safe and can handle real-time elements quite well. You'll definitely learn a lot.
harbinger 5 months ago prev next
Definitely recommend using a websocket client here — I had a smooth experience with tokio-tungstenite. Is there a specific backend you're using?
mavenscar 5 months ago next
@harbinger The backend we used for our project is Diesel but Swimm is a quite interesting alternative. It provides a simple way to create REST APIs with async Rust and integrates very well with the rest of the ecosystem!
lady_byte 5 months ago prev next
Is this the most efficient way to handle scaling real-time chat considering there's so much State being carried around? I can't imagine that this is feasible in volatile situations.
zeph_byte 5 months ago next
@lady_byte I agree that this implementation may not be the most efficient. To handle scaling/volatile situations efficiently, would we opt for something like a distributed message queue like Kafka or RabbitMQ? Looking forward to some insights!
primecoder 5 months ago prev next
This is a fantastic introduction! I'm excited to explore the Crate ecosystem and give Redis a try for cache management. Any particular libraries you'd suggest for efficiently handling cache expiration?
tenacious 5 months ago next
@primecoder Redis has its own set of client libraries for Rust! The one I can think of off the top of my head is `redis-rs`. It allows you to use connection pools and has support for publish/subscribe events. Definitely worth checking out!
morphinghazard 5 months ago prev next
Also interested to know about performance monitoring; what is the best option for taking the pulse of request rates, response times, and other key performance indicators for this kind of project?
hail_byte 5 months ago next
@morphinghazard While there are many options for request/response monitoring, we found prometheus-rs worked well for us. It has both support for performance metrics and alerting. Check it out!
smol_genius 5 months ago prev next
Do you have any recommendations for deploying the real-time chat app to the cloud? Fei Chaang mentioned deploying a Rust application to AWS Lambda, and I'd love to know what sort of obstacles one might face with that setup.
primerazor 5 months ago next
@smol_genius AWS Lambda does not support Rust natively, and so you must run Rust within a Docker container. This provides an extra level of complication as containerizing Rust applications requires additional efforts to manage dependencies and image size. However, I suppose the trade-off would convert your app into a managed service, which can certainly be worthwhile for many projects.