Managing multiple connections

114 views
Skip to first unread message

Izaak

unread,
Nov 13, 2014, 1:03:36 PM11/13/14
to libst...@googlegroups.com
Hi, 

I want to write a simulation program that connects many XMPP users together and generates artificial conversation between them. Everything will be generated by the system: user information, conversation, duration of connections, etc. I imagine it will operate by functioning as a sort of multi-account client -- it sends and receives from the XMPP server and sends messages to the corresponding user locally. 

I looked at the documentation for libstrophe, but I am not sure how to deal with multiple connections in the same program because it appears that updates are bound to a context. It seems I would have to create a new context for every connection, then call xmpp_run_once for every context. Is this correct? If so, I want to do this with ~10k users (and therefore 10k connections), so will I run into problems? 

Any advice is appreciated.

--
Izaak

Dmitry Podgorny

unread,
Nov 13, 2014, 5:43:01 PM11/13/14
to libst...@googlegroups.com
Hello,

Simple usecase for 1 context and many multiple connections:

    ctx = xmpp_ctx_new(NULL, NULL);
    conn1 = xmpp_conn_new(ctx);
    conn2 = xmpp_conn_new(ctx);

    xmpp_conn_set_jid(conn1, jid);
    xmpp_conn_set_pass(conn1, pass);
    xmpp_connect_client(conn1, host, 0, conn_handler, ctx);

    xmpp_conn_set_jid(conn2, jid);
    xmpp_conn_set_pass(conn2, pass);
    xmpp_connect_client(conn2, host, 0, conn_handler, ctx);

    xmpp_run(ctx); /* or run_once() */


But I wonder if you will be able to hadle 10k connections without performance issues. Libstrophe is not optimized to handle so many connections. Anyway, it would be great if you shared with your results.

Izaak

unread,
Nov 13, 2014, 7:08:07 PM11/13/14
to libst...@googlegroups.com

On Thursday, 13 November 2014 23:43:01 UTC+1, Dmitry Podgorny wrote:
Simple usecase for 1 context and many multiple connections:
Thank you for the example -- this seems straightforward.
 
But I wonder if you will be able to hadle 10k connections without performance issues. Libstrophe is not optimized to handle so many connections. Anyway, it would be great if you shared with your results.
I expect that I will indeed run into performance problems after ~1000 connections. If that occurs, I am planning to make a simple distributed system, so that a controller co-ordinates distribution of new conversations between several nodes where a single node handles ~1000 conversations. It is not certain if I even need to write this program yet, so I will not make any promises -- of course, if I make it, I will report back.

--
Izaak
Reply all
Reply to author
Forward
0 new messages