Wanted to design chat and group chat in optimized way

311 views
Skip to first unread message

Rambabu

unread,
Jul 8, 2015, 5:00:43 AM7/8/15
to rabbitm...@googlegroups.com
Hi,

I would like to implement chat(one to one) and group chat using rabbitmq. It should be scalabe to millions of users.
Can anybody suggest best ways?

I am having following doubts
1. Do every producer/consumer need to maintain connection always? ( for incoming messages)
2. Every consumer and producer should have queue?
3. Do we need to create exchange for each chat group and one to one chat?
4. What could be the maximum limits of connections, exchanges and queues?
I observered each empty queue is taking around 8k of memory, each connection is taking 60k, exchanges are taking very little memory. If each produer/consumer has one connection and one queue it will be huge memory consumption. Please suggest me better ways.

Thanks

Michael Klishin

unread,
Jul 8, 2015, 10:51:57 AM7/8/15
to rabbitm...@googlegroups.com, Rambabu
 On 8 July 2015 at 12:00:45, Rambabu (rambabu...@gmail.com) wrote:
> 1. Do every producer/consumer need to maintain connection
> always? ( for incoming messages)

Yes, all protocols that RabbitMQ supports assume long lived connections.

> 2. Every consumer and producer should have queue?

Producers don't use queues but some may argue that having a reply queue (see Tutorial 6)
is pattern when producers temporarily do. Not sure if this answers your question.

> 3. Do we need to create exchange for each chat group and one to one
> chat?

You can publish "directly" to a queue using default exchange but for
better isolation of chat rooms it's a good idea.

> 4. What could be the maximum limits of connections, exchanges
> and queues?

For connections and queues, amount of RAM: see http://www.rabbitmq.com/networking.html.

For exchanges, I honestly can't remember anybody to running into
an issue because of too many exchanges.

> I observered each empty queue is taking around 8k of memory, each
> connection is taking 60k, exchanges are taking very little memory. 

The amount of RAM used by connections is directly related to TCP buffer
configuration. 60K sounds too low (with stock Linux and OS X settings
on 64 bit machines).

> If each produer/consumer has one connection and one queue it
> will be huge memory consumption. Please suggest me better ways.

You can greatly reduce amount of RAM used by connections at the cost
of throughput, as described on http://www.rabbitmq.com/networking.html.
You can (and probably will) run more than one node and distribute connections
between them. This should help distribute queue masters (currently a queue is hosted
on the node it was declared on).

Depending on your requirements, having queue or message TTL (or queue size limit)
may be appropriate and it can help you reduce peak RAM use.

If I was building a chat app today, I'd look into XMPP first (e.g. ejabberd),
not RabbitMQ.
--
MK

Staff Software Engineer, Pivotal/RabbitMQ


Rambabu

unread,
Jul 9, 2015, 8:28:19 AM7/9/15
to rabbitm...@googlegroups.com, rambabu...@gmail.com

Thank you Michael for your response.
 I will get back to you if i have more questions

Regards
Rambabu

Rambabu

unread,
Jul 28, 2015, 1:54:17 PM7/28/15
to rabbitmq-users, rambabu...@gmail.com
Hi 

Is there any acknowledgement from broker after published? If so how to map acknowledgement to published message?

I didn't observer any return value from basicPublish method.

Thanks & Regards
Rambabu Kodati

Michael Klishin

unread,
Jul 28, 2015, 2:38:19 PM7/28/15
to rabbitmq-users, Rambabu
On 28 Jul 2015 at 20:54:21, Rambabu (rambabu...@gmail.com) wrote:
> Is there any acknowledgement from broker after published?
> If so how to map acknowledgement to published message?
>
> I didn't observer any return value from basicPublish method.

http://www.rabbitmq.com/confirms.html

Publishing is entirely asynchronous. Confirmations are as well. Channels have a counter
(sequences) for published messages. 

Rambabu

unread,
Aug 7, 2015, 3:42:01 AM8/7/15
to rabbitmq-users, rambabu...@gmail.com
Hi,

I am using per message TTL. I observed message reached to consumer after expiry time is over.

Scenario:
Consumer is not running.
Send 1 sec expiry TTL message from producer.
After 5 secs run the consumer. Observed that consumer receiving expiry message sent by producer.(It should be discarded)

Please help me to discard message after expiry time.

Thanks & Regards
Rambabu

I have added expiration to message (per message TTL). Consumer is receiving message after expiry time is over instead

Michael Klishin

unread,
Aug 7, 2015, 6:30:55 AM8/7/15
to rabbitm...@googlegroups.com, rambabu...@gmail.com
Please post your code and rabbitmqctl list_queues output. It is almost certainly an issue with publisher or queue attributes.

MK
--
You received this message because you are subscribed to the Google Groups "rabbitmq-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rabbitmq-user...@googlegroups.com.
To post to this group, send email to rabbitm...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rambabu

unread,
Aug 7, 2015, 8:35:07 AM8/7/15
to rabbitmq-users, rambabu...@gmail.com
Hi Michael,

It worked with following code
BasicProperties properties = new BasicProperties.Builder().expiration("60000").build();

Earlier tried with code mentioned in https://www.rabbitmq.com/ttl.html  and getting builder from properties individually. But it was not worked.
AMQP.BasicProperties properties = new AMQP.BasicProperties();
properties.setExpiration("60000");


Thanks

Michael Klishin

unread,
Aug 7, 2015, 9:20:35 AM8/7/15
to rabbitm...@googlegroups.com, Rambabu
On 7 Aug 2015 at 15:35:10, Rambabu (rambabu...@gmail.com) wrote:
> It worked with following code
> BasicProperties properties = new BasicProperties.Builder().expiration("60000").build();

This is not a 1 second expiry but 60 seconds.

I cannot reproduce your issue with several clients: messages that have
expiration set correctly do expire. Make sure you run a recent RabbitMQ version,
message TTL was added in 3.0:
http://www.rabbitmq.com/changelog.html 

Rambabu

unread,
Aug 11, 2015, 8:57:53 AM8/11/15
to rabbitmq-users, rambabu...@gmail.com
Hi Michael,

I have a situation that consumer became off-line forever. In that case how can i identify and remove that consumer queue and exchange?(Queue is persistent).

Thanks

Alvaro Videla

unread,
Aug 11, 2015, 9:11:59 AM8/11/15
to rabbitm...@googlegroups.com, rambabu...@gmail.com
Take a look at the queue.delete flag "if unused" here: https://www.rabbitmq.com/amqp-0-9-1-quickref.html

You could list queues using something like the management plugin and then delete those that are not being used.

Michael Klishin

unread,
Aug 11, 2015, 9:14:17 AM8/11/15
to rabbitm...@googlegroups.com, Alvaro Videla
On 11 Aug 2015 at 16:11:59, Alvaro Videla (videl...@gmail.com) wrote:
> Take a look at the queue.delete flag "if unused" here: https://www.rabbitmq.com/amqp-0-9-1-quickref.html.
>
> You could list queues using something like the management plugin
> and then delete those that are not being used.

Or use  auto-delete queues.

Michael Klishin

unread,
Aug 11, 2015, 9:15:07 AM8/11/15
to rabbitm...@googlegroups.com, rambabu...@gmail.com
On 11 Aug 2015 at 16:11:59, Alvaro Videla (videl...@gmail.com) wrote:
> I have a situation that consumer became off-line forever. In
> that case how can i identify and remove that consumer queue and
> exchange?(Queue is persistent).

Auto-delete queues, exclusive queues (deleted when connection that declared them is lost
or closed), queue TTL (not message TTL!)

Please start new threads for new questions.
Reply all
Reply to author
Forward
0 new messages