[zeromq-dev] Socket usage question

Gary Davidson Gary.Davidson at interclick.com
Wed Aug 24 15:14:36 CEST 2011

1000 iterations creating and destroying 1000 sockets? Use Environment.ProcessorCount in your loop and send msgcount\ Environment.ProcessorCount messages in each task.

Alternatively you can use TPL Parallel.For.

To simulate load use the cloud. I had 5 clients sending to 1 server at 269K messages per second with the CPU  never exceeding 30% the network card was saturated though.

Even on my I7 laptop to my mac book I get excellent through put.

Currently you have thread context switching issues. You can verify this using performance counters if they will even load which I doubt.

Gary Davidson | Chief Software Architect | interclick

Gary.Davidson at interclick.com
P 561 300 2764  |  C 954 790 0715  |  F 561 300 2765
4800 T-Rex Avenue Suite 120 Boca Raton, FL 33431
www.interclick.com    NASDAQ: ICLK
-----Original Message-----
From: zeromq-dev-bounces at lists.zeromq.org [mailto:zeromq-dev-bounces at lists.zeromq.org] On Behalf Of Matt Haberman
Sent: Tuesday, August 23, 2011 10:10 PM
To: zeromq-dev at lists.zeromq.org
Subject: [zeromq-dev] Socket usage question

I am trying simulate load on a process created with 0MQ (CLZMQ2 binding) and have a question about when to create sockets. My application is listening for requests using an XREP socket. I wrote a little console app to simulate concurrent clients that looks like:

public class Client
    Context context;

    public Client()
        context = new Context(1);
    public void SendRequest()
        for (int i = 1; i <= 1000; i++)
            Task t = new Task(
                () =>
                    Socket r = context.Socket(SocketType.REQ);

                    r.Send("Hello", Encoding.Unicode);
                    string reply = r.Recv(Encoding.Unicode);
                    Console.WriteLine("Received reply {0}", reply);
Frequently, when i run the console app my entire machine freezes and is unresponsive. Is there something wrong with this approach?

zeromq-dev mailing list
zeromq-dev at lists.zeromq.org

More information about the zeromq-dev mailing list