Zend certified PHP/Magento developer

Curl Vs Spring RestTemplate.exchange – huge performance diffrence

Under what circumstances a Restful call made with curl would be much faster than Spring’s RestTemplate

I have to use Spring’s RestTemplate’s exchange methods as I am sending a JWT token as an Http Header (amongst others). The URL sits behind a DNS load balancer.

So curl command simply looks like
curl -X POST “url” -H ‘accept: /‘ -H Content-Type: application/json’
-H ‘Bearer: ‘ -d “body”

I am noticing 10 times the difference in Spring’s RestTemplate (slower) as against curl call. So if curl returns the response in 1 second, the same is achieved by RestTemplate in no less than 11 or 12 seconds.