问题描述
我正在制作一个聊天应用.有一张你自己的照片.您可以向其他人发送消息,当他们收到消息时,他们也会收到您的头像.
I am making a chat app. There is a pic of yourself. You can send messages to other people and when they receive the message they receive your avatar too.
诀窍在于图像会消耗资源,而且不会经常更改.RabbitMQ
适合交换头像吗?还是需要自己设计系统?
The trick is that images cost resources and they don't change that often. Is RabbitMQ
suited for exchanging avatars ? Or do I need to design my own system ?
P.S:我是 RabbitMQ
的新手,但我有编写应用程序、服务器等方面的经验......
P.S : I'm new to RabbitMQ
but Im experienced with writing apps, servers, ...
推荐答案
简述:是的,从技术上讲,它可以使用.但是最好发送指向单独提供的图像的链接,例如从 CDN 或仅从您的网络服务器发送.
In brief:Yes, technically, it may be used. But it would be better to send link to image that served separately, say, from CDN or just from your web-server.
长答案:RabbitMQ 可以处理大负载(我测试了 2GB,它的工作原理很吸引人)但它不是为此而设计的.当队列适合内存时,RabbitMQ 效果最佳.即使消息被转储到磁盘(如果您希望您的消息在 RabbitMQ 重新启动后永久可用,我想这就是您的情况,也不要忘记使队列也是永久的)保持消息与您一样小总是会更快可以(没有任何副作用).此外,大多数应用程序(网络或特定于平台的)使用缓存,因此下载一次头像图像,然后在需要时显示它绝对是更快且资源友好的方式,而不是每次都发送该二进制文件.
Long answer:RabbitMQ can handle large payload (I tested 2GB and it works like a charm) but it doesn't designed for that. RabbitMQ works best when queue fits in memory. Even if messages get dumped to disk (I guess this is your case if you want your messages be permanent and available after RabbitMQ restart, also don't forget to make queues also permanent) it always will be faster to keep message as small as you can (without any side performance degradation). Also, most apps (web or platform-specific) use caching, so downloading avatar image once and then just display it whenever you need would be definitely faster and resource-friendly way rather then send that binary every time.
这篇关于rabbitMQ 可以用于聊天服务器中的头像吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!