I’m currently using the Apache HTTP Client and running a multithreaded solution, currently I’m spawning a new thread for each httppost that I perform. Is there any way to make this execute faster? I don’t need to do anything with the content that is returned, I only need to send my request.
I have mainly used the code provided http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d5e639 in step 2.9.
Assuming you’re going to need this to run for a long time, you could save some execution time if you pre-create the threads, so you don’t have to spawn them for every request. The performance gain will be small but it’s still better than nothing. Take a look at Java Executors.
Also, make sure that as far as Apache HTTP Client usage is concerned, that you’re not creating objects you don’t need. For example, if you know (in advance) where your requests are sent to, you may want to hold an HTTP connection pool instead of establishing connections every time you need to send a request.