java - Httprest performance improvement -
i doing httprest post call send data third party, data in order of 3 10 million , can send 1 record per request along username , password authentication specified third party
sample code using
public static void main(string[] args) { try { defaulthttpclient httpclient = new defaulthttpclient(); httppost postrequest = new httppost( "http://localhost:8080/restfulexample/json/product/post"); stringentity input = new stringentity("{\"qty\":100,\"name\":\"ipad 4\"}"); input.setcontenttype("application/json"); postrequest.setentity(input); httpresponse response = httpclient.execute(postrequest); if (response.getstatusline().getstatuscode() != 201) { throw new runtimeexception("failed : http error code : " + response.getstatusline().getstatuscode()); } bufferedreader br = new bufferedreader( new inputstreamreader((response.getentity().getcontent()))); string output; system.out.println("output server .... \n"); while ((output = br.readline()) != null) { system.out.println(output); } } catch (malformedurlexception e) { e.printstacktrace(); } catch (ioexception e) { e.printstacktrace(); } } for each request taking around 6 sec , if calculate 10 million records take hours , can 1 please suggest me ways improve performance ??
thanks in advance sunny
first, if 1 request takes 6 seconds, 10 million records take 115 days. should reduce response time 6 seconds several hundred of milliseconds first before use multithread tech increase performance cilent side.
Comments
Post a Comment