hc-httpclient-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From S Ahmed <sahmed1...@gmail.com>
Subject Re: simple load tester, tips on make my http post call fast and effecient
Date Fri, 04 Oct 2013 14:51:43 GMT
Oleg, great thanks for your advice, httpcore-ab looks perfect (thought
looking at the source it doesn't seem to be using httpclient but it makes a
raw socket connection etc.)

BenchmarkWorker.java:
                    final int timeout = config.getSocketTimeout();
                    socket.setSoTimeout(timeout);
                    socket.connect(new InetSocketAddress(hostname, port),
timeout);

                    conn.bind(socket);

A few questions:

1. how do I set the timeout with httpclient?
    CloseableHttpClient httpClient = HttpClients.createDefault();

2.  I get a warning that says FileEntity is deprecated, what should I be
using instead?

 httpPost.setEntity(new FileEntity(xmlFile, "text/xml, application/xml"));


Thanks!


On Fri, Oct 4, 2013 at 4:23 AM, Oleg Kalnichevski <olegk@apache.org> wrote:

> On Thu, 2013-10-03 at 17:19 -0400, S Ahmed wrote:
> > I want to create a simple load tester that posts a file to a service
> > endpoint.
> >
> > 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
> > please.
> >
> > I am creating a single instance of the client that I will pass to this
> > function:
> >
>
> You code looks all right to me. However, you should probably consider
> using an exiting load tool instead of building it yourself.
>
> For instance, HttpCore (the component kit HttpClient is based upon)
> ships with a Apache Bench (AB) clone [1]. If you are familiar with the
> original 'ab' [2] you will find 'httpcore-ab' pretty straight-forward .
> If you want to study the source you can find it here [3] or in the
> source distribution of HttpCore.
>
> Oleg
>
> [1]
>
> http://hc.apache.org/httpcomponents-core-4.3.x/httpcore-ab/project-info.html
> [2]
> http://httpd.apache.org/docs/2.2/programs/ab.html
> [3]
>
> http://svn.apache.org/repos/asf/httpcomponents/httpcore/trunk/httpcore-ab/src/main/java/org/apache/http/benchmark/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

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