title: How to program to handle multiple simultaneous requests from different clients?
body: <pre><code>public class CassandraData {
  
      private static Session cassandraSession = null;
      private static Cluster cluster = null;
  
      CassandraData() {
          // Do nothing
      }
  
      static {
  
          if (cassandraSession == null) {
              QueryOptions qs = new QueryOptions().setConsistencyLevel(ConsistencyLevel.LOCAL_QUORUM);
  
              PoolingOptions poolingOptions = new PoolingOptions();
              poolingOptions.setConnectionsPerHost(HostDistance.LOCAL, 2, 10).setConnectionsPerHost(HostDistance.REMOTE,
                      10, 20);
  
              SocketOptions socketOptions = new SocketOptions();
              socketOptions.setConnectTimeoutMillis(60000);
              socketOptions.setReadTimeoutMillis(600000);
  
              cluster = Cluster.builder().addContactPoints("***.***.***.***").withQueryOptions(qs)
                      .withPoolingOptions(poolingOptions).withSocketOptions(socketOptions)
                      .withLoadBalancingPolicy(new RoundRobinPolicy()).build();
  
              cassandraSession = cluster.connect("sf");
          }
          // monitor();
      }
  
      public Session getSession() {
  
          return cassandraSession;
  
      }
      public Data findOne(PK pk) {
  
          Data mc = null;
  
          Statement statement = new SimpleStatement(getCqlString(pk));
  
          ResultSet results = getSession().execute(statement);
  
  
          List&lt;Row&gt; rowList = results.all();
  
          if (rowList != null &amp;&amp; rowList.size() &gt; 0) {
              Row row = rowList.get(0);
              mc = EntityConvert.ConvertToMC(row);
          }
  
          return mc;
      }
  }
      private String getCqlString(PK pk) {
      String cqlStr = "select * from table" + " where E='"
              + pk.E + "' and D=" + pk.D + " and M="
              + pk.M;
      return cqlStr;
  }
  </code></pre>
  
  <p>Servlet:</p>
  
  <pre><code>public class OneServlet extends HttpServlet {
      private static final long serialVersionUID = 1L;
      private static final Logger logger = LogManager.getLogger(OneServlet.class);
      /**
       * @see HttpServlet#HttpServlet()
       */
      public OneServlet() {
          super();
      }
  
      /**
       * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
       *      response)
       */
      protected void doGet(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
  
          response.setContentType("application/json; charset=utf-8");
          response.setCharacterEncoding("UTF-8");
          long start = System.currentTimeMillis();
  
          PK pk = ValidData.getOnePk();
  
          CassandraData dataAccess = new CassandraData();
          long end2 = System.currentTimeMillis();
          Data mc = dataAccess.findOne(pk);
  
          String rsJson = JSON.toJSONString(mc);
          long end = System.currentTimeMillis();
  
          logger.info("Create CassandraData:" + (end2 - start)/1000.0 +"s elapsed." + "Show One:" + (end - start)/1000.0 +"s elapsed.");
  
          OutputStream out = response.getOutputStream();
          out.write(rsJson.getBytes("UTF-8"));
          out.flush();
      }
  
      /**
       * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
       *      response)
       */
      protected void doPost(HttpServletRequest request, HttpServletResponse response)
              throws ServletException, IOException {
          doGet(request, response);
      }
  
  }
  </code></pre>
  
  <p>In my Servlet application, I'd like to use the above code to access cassandra.
  When a user accesses the Servlet, it will take average 0.1s to fetch the data.
  When multiple users, like 60, access the Servlet, each request will take average 20s to fetch the data.<br>
  Due to multiple users, how should I modify this code to reduce the requst time?</p>