title: Solr 6.0.0 - SolrCloud java example
body: <p>I have solr installed on my localhost.</p>
  
  <p>I started <strong>standard solr cloud example</strong> with embedded zookeepr.</p>
  
  <p>collection: gettingstarted
  shards: 2
  replication : 2</p>
  
  <p><strong>500 records/docs to process time took 115 seconds[localhost tetsing] - 
  why is this taking this much time to process just 500 records.
  is there a way to improve this to some millisecs/nanosecs</strong></p>
  
  <p>NOTE:</p>
  
  <p>I have tested the same on remote machine solr instance, localhost having data index on remote solr [inside java commented]</p>
  
  <p>I started <strong>my solr myCloudData collection</strong> with Ensemble with single zookeepr.</p>
  
  <p><strong>2 solr nodes,
  1 Ensemble zookeeper standalone</strong></p>
  
  <p>collection: myCloudData,
  shards: 2,
  replication : 2</p>
  
  <p>Solr colud java code </p>
  
  <pre><code>package com.test.solr.basic;
  
  import java.io.IOException;
  import java.util.concurrent.TimeUnit;
  
  import org.apache.solr.client.solrj.SolrClient;
  import org.apache.solr.client.solrj.SolrServerException;
  import org.apache.solr.client.solrj.impl.CloudSolrClient;
  import org.apache.solr.client.solrj.impl.HttpSolrClient;
  import org.apache.solr.common.SolrInputDocument;
  
   public class SolrjPopulatorCloudClient2 {
    public static void main(String[] args) throws     IOException,SolrServerException {           
  
  
      //String zkHosts = "64.101.49.57:2181/solr";
      String zkHosts = "localhost:9983";
      CloudSolrClient solrCloudClient = new CloudSolrClient(zkHosts, true);
      //solrCloudClient.setDefaultCollection("myCloudData");
      solrCloudClient.setDefaultCollection("gettingstarted");
      /*
      // Thread Safe
      solrClient = new ConcurrentUpdateSolrClient(urlString, queueSize, threadCount);
      */
      // Depreciated - client
      //HttpSolrServer server = new HttpSolrServer("http://localhost:8983/solr");
      long start = System.nanoTime();
      for (int i = 0; i &lt; 500; ++i) {
          SolrInputDocument doc = new SolrInputDocument();
          doc.addField("cat", "book");
          doc.addField("id", "book-" + i);
          doc.addField("name", "The Legend of the Hobbit part " + i);
          solrCloudClient.add(doc);
          if (i % 100 == 0)
              System.out.println(" Every 100 records flush it");
          solrCloudClient.commit(); // periodically flush
      }
      solrCloudClient.commit(); 
      solrCloudClient.close();
      long end = System.nanoTime();
      long seconds = TimeUnit.NANOSECONDS.toSeconds(end - start);
      System.out.println(" All records are indexed, took " + seconds + " seconds");
  
   }
  }
  </code></pre>