[zeromq-dev] transmission rate of broker is less than 5000req/s

Elwin.Gao elwin.gao4444 at gmail.com
Tue Aug 21 12:28:50 CEST 2012


> You're switching from a synchronous REQ/REP pair to a ROUTER/DEALER pair.
> 
> Like I said, round-tripping is slow.
> 
> More on this topic: http://zguide.zeromq.org/page:all#toc71
> 
> -Pieter
> 

i wrote a experiment, it's the same problem. but one socket 
in one thread, speed is very quick no matter which mode, but
two socket(or more) in one thread is will be very very slow.

i want to design a program like this:
one server use PUB send msg to every worker, and each worker
recv these datas(using SUB), then reply with DEALER, server recv
with ROUTER so than server will know which worker the data from.

the experiment i wrote if following:

server.c :
int main(int argc, char *argv[])                                                
{
        void *context = zmq_init(1);
        void *sender = zmq_socket(context, ZMQ_DEALER);
        void *recver = zmq_socket(context, ZMQ_DEALER);
        zmq_bind(sender, "tcp://*:60001");
        zmq_bind(recver, "tcp://*:60002");

        uint64_t start = s_clock();
        int i;
        for (i=0; i<10000; ++i) {
                s_send(sender, "hello");
                char *data = s_recv(recver);
//              puts(data);
                free(data);
//              sleep(1);
        }   
        uint64_t end = s_clock();
        uint64_t diff = end - start;
        printf("Using time: %2lu:%04lu\n", diff/1000, diff%1000);
        return EXIT_SUCCESS;
}

worker.c : 
int main(int argc, char *argv[])
{
        void *context = zmq_init(1);
        void *sender = zmq_socket(context, ZMQ_DEALER);
        void *recver = zmq_socket(context, ZMQ_DEALER);
        zmq_connect(sender, "tcp://*:60002");
        zmq_connect(recver, "tcp://*:60001");

        uint64_t start = s_clock();
        int i;
        for (i=0; i<10000; ++i) {
                char *data = s_recv(recver);
                s_send(sender, "world");
                free(data);
        }   
        uint64_t end = s_clock();
        uint64_t diff = end - start;
        printf("Using time: %2lu:%04lu\n", diff/1000, diff%1000);
        return EXIT_SUCCESS;
}




More information about the zeromq-dev mailing list