Add wait states to deal with many connections.
[redis.git] / src / redis-benchmark.c
index ab0d9230c89840a7f9c8e956b0b64cbc36d66186..df3b85fd809ca152e6c5ed2509aa5be72e8a8588 100644 (file)
@@ -278,11 +278,22 @@ static client createClient(int replytype) {
 }
 
 static void createMissingClients(client c) {
+    int n = 0;
+
     while(config.liveclients < config.numclients) {
         client new = createClient(c->replytype);
         new->obuf = sdsdup(c->obuf);
         if (config.randomkeys) randomizeClientKey(c);
+
+        /* Listen backlog is quite limited on most systems */
+        if (++n > 64) {
+            usleep(50000);
+            n = 0;
+        }
     }
+
+    /* Start the timer once the connection are established */
+    config.start = mstime();
 }
 
 static int compareLatency(const void *a, const void *b) {