I have a script written in PHP that sends an API call to eBay. There are several (15-50) calls made every second. I did some benchmarking and noticed that PHP doesn’t execute these as fast as I’d like since it doesn’t run them in parallel.
My question: Is it a good idea to convert the script into Java, so as to give it multi-threaded capabilities? Will this even run each request in parallel like I think it would or am I misguided to believe so?
Any other suggestions are welcomed.
Thanks.
First, rewriting your script in Java is not going to magically make it multithreaded, and unless you have experience with concurrent programming I would avoid this. Even then this doesn’t necessarily mean it will run faster than your PHP script.
Second, PHP can execute multiple http requests in parallel using cURL’s multi exec functions. See the docs for curl_multi_init and curl_multi_exec for how to use them.