hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S Ahmed <sahmed1...@gmail.com>
Subject simple load tester, tips on make my http post call fast and effecient
Date Thu, 03 Oct 2013 21:19:35 GMT
I want to create a simple load tester that posts a file to a service

Are there any existing samples that have all the best-practices in place
and that also does this in a group of threads?

As a starting point, can you guys critique my method that posts a file

I am creating a single instance of the client that I will pass to this

CloseableHttpClient httpClient = HttpClients.createDefault();

private static int PostToApi(CloseableHttpClient httpClient, File xmlFile)
throws IOException {

        HttpPost httpPost = new HttpPost("http://localhost:8090/a/b/c/");
        httpPost.setEntity(new FileEntity(xmlFile, "text/xml,

        CloseableHttpResponse response = httpClient.execute(httpPost);

        int responseCode = 0;

        try {
            BufferedReader reader = new BufferedReader(new

            String line = "";
            while ((line = reader.readLine()) != null) {
                if(line.equals("OK")) {
                    responseCode = 1;
        } finally {

        return responseCode;

What can I do to make this more stable and fast/effecient etc?

This is for load testing and it will be called thousands of times per
second hopefully so I want some advice on how to clean it up.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message