connection pooling with cassandra-driver for nodejs
<p>i have wrote a small application to understand the concept connection pooling in cassandra. i am testing it using Apache bench tool. however the app sometimes shows the error and closes the connections in between. and then it throws error like host is down. when i give request for 1,00,000 queries with concurrency of 1000. it executes successfully but if i try to increase concurrency, then it ends up closing socket and eventually it shows host is down. so what my questions are is there a limit on concurrent requests that cassandra can serve? <a href="http://datastax.github.io/nodejs-driver/features/connection-pooling/" rel="nofollow">limit</a> is approximateky 32K requests without waiting for response as i am using cassandra 3.0. </p>

<ol>
<li><p>does that means i can have that much concurrent request running?</p></li>
<li><p>whats the reason behind getting this errors? for some inputs and not for all. </p></li>
<li>how exactly connection pooling works in cassandra as we can
only set the number of coreConnections per host and not the number
of requests per connection?</li>
</ol>

<p>here is the test file i made.</p>

<pre><code>var cassandra = require("cassandra-driver");
  var express    = require("express");
  var distance = cassandra.types.distance;


  var cassClient = new cassandra.Client({contactPoints: ['myhost'],pooling: {
        coreConnectionsPerHost: {
          [distance.local] : 2,
          [distance.remote] : 1
        } 
     }, keyspace: 'MY_DB'});

  var app = express();
    cassClient.connect(function( err ){
      if( err ){
        console.log("Error: Connection to cassandra server."+err);
      } else {
        console.log("Success !!!");
      }
    });

  var i =0;
  app.get("/",function(req,res){
  cassClient.execute('SELECT * from mytable LIMIT 2', function(err, rows) {
  //cassClient.shutdown();
    if (!err){   
    //  console.log('The solution is: ' +i);
      return res.send();
      }
    else
      {

        i++;
        console.log(err.message +"  "+i);
        return res.send();
      }
    });
   // cassClient.nwd();
  });

  app.listen(3001);
</code></pre>

<p>the errors i am getting are </p>

<ul>
<li>All host(s) tried for query failed. First host tried, myhost:9042: Host considered as DOWN. See innerErrors.</li>
<li>All host(s) tried for query failed. First host tried, myhost:9042: Error: Socket was closed. See innerErrors.</li>
<li>All host(s) tried for query failed. First host tried, myhost:9042: OperationTimedOutError: The host myhost:9042 did not reply before timeout 12000 ms. See innerErrors.</li>
</ul>

<p>so why is it happening? </p>