public void run() {
      try {
        System.out.println("Starting write server performance");
        long numberOfPuts = 0;
        long timePassedInNanoSeconds = 0;
        long maxLatencyInNanoSeconds = 0;
        long minLatencyInNanoSeconds = Long.MAX_VALUE;
        long totalLatencyInNanoSeconds = 0;
        ArrayList<Long> latenciesForPutBlobs = new ArrayList<Long>();
        while (!isShutdown.get()) {

          int randomNum = rand.nextInt((maxBlobSize - minBlobSize) + 1) + minBlobSize;
          byte[] blob = new byte[randomNum];
          byte[] usermetadata = new byte[new Random().nextInt(1024)];
          BlobProperties props =
              new BlobProperties(randomNum, "test", Account.UNKNOWN_ACCOUNT_ID, Container.UNKNOWN_CONTAINER_ID, false);
          ConnectedChannel channel = null;
          try {
            List<? extends PartitionId> partitionIds = clusterMap.getWritablePartitionIds(null);
            int index = (int) getRandomLong(rand, partitionIds.size());
            PartitionId partitionId = partitionIds.get(index);
            BlobId blobId = new BlobId(blobIdVersion, BlobId.BlobIdType.NATIVE, clusterMap.getLocalDatacenterId(),
                props.getAccountId(), props.getContainerId(), partitionId, false, BlobId.BlobDataType.DATACHUNK);
            PutRequest putRequest =
                new PutRequest(0, "perf", blobId, props, ByteBuffer.wrap(usermetadata), Unpooled.wrappedBuffer(blob),
                    props.getBlobSize(), BlobType.DataBlob, null);
            ReplicaId replicaId = partitionId.getReplicaIds().get(0);
            Port port = replicaId.getDataNodeId().getPortToConnectTo();
            channel = connectionPool.checkOutConnection(replicaId.getDataNodeId().getHostname(), port, 10000);
            long startTime = SystemTime.getInstance().nanoseconds();
            channel.send(putRequest);
            PutResponse putResponse = PutResponse.readFrom(channel.receive().getInputStream());
            if (putResponse.getError() != ServerErrorCode.NoError) {
              throw new UnexpectedException("error " + putResponse.getError());
            }
            long latencyPerBlob = SystemTime.getInstance().nanoseconds() - startTime;
            timePassedInNanoSeconds += latencyPerBlob;
            latenciesForPutBlobs.add(latencyPerBlob);
            blobIdWriter.write("Blob-" + blobId + "\n");
            totalWrites.incrementAndGet();
            if (enableVerboseLogging) {
              System.out.println("Time taken to put blob id " + blobId + " in ms " + latencyPerBlob / SystemTime.NsPerMs
                  + " for blob of size " + blob.length);
            }
            numberOfPuts++;
            if (maxLatencyInNanoSeconds < latencyPerBlob) {
              maxLatencyInNanoSeconds = latencyPerBlob;
            }
            if (minLatencyInNanoSeconds > latencyPerBlob) {
              minLatencyInNanoSeconds = latencyPerBlob;
            }
            totalLatencyInNanoSeconds += latencyPerBlob;
            if (timePassedInNanoSeconds >= measurementIntervalNs) {
              Collections.sort(latenciesForPutBlobs);
              int index99 = (int) (latenciesForPutBlobs.size() * 0.99) - 1;
              int index95 = (int) (latenciesForPutBlobs.size() * 0.95) - 1;
              String message = threadIndex + "," + numberOfPuts + ","
                  + (double) latenciesForPutBlobs.get(index99) / SystemTime.NsPerSec + ","
                  + (double) latenciesForPutBlobs.get(index95) / SystemTime.NsPerSec + "," + (
                  ((double) totalLatencyInNanoSeconds) / SystemTime.NsPerSec / numberOfPuts);
              System.out.println(message);
              performanceWriter.write(message + "\n");
              numberOfPuts = 0;
              timePassedInNanoSeconds = 0;
              latenciesForPutBlobs.clear();
              maxLatencyInNanoSeconds = 0;
              minLatencyInNanoSeconds = Long.MAX_VALUE;
              totalLatencyInNanoSeconds = 0;
            }
            totalTimeTaken.addAndGet(latencyPerBlob);
            throttler.maybeThrottle(1);
          } catch (Exception e) {
            System.out.println("Exception when putting blob " + e);
          } finally {
            if (channel != null) {
              connectionPool.checkInConnection(channel);
            }
          }
        }
      } catch (Exception e) {
        System.out.println("Exiting server write perf thread " + e);
      } finally {
        latch.countDown();
      }
    }
Generates load for write performance test
ambry-tools/src/main/java/com/github/ambry/tools/perf/ServerWritePerformance.java