In the process of migrating our docker infrastructure to a docker swarm cluster we are experiencing performance issues when containerized APIs are calling outside ressources (e.g. elasticsearch queries to elastic cloud, or other API's on MS Azure, etc.)
Our first investigations have shown that 1) queries from the hosts are not affected, only traffic from containers is delayed, and 2) the first query in an http session suffers a ~4 seconds delay but subsequent queries are much faster.
So IMO we perhaps suffer an issue with name solving and/or load balancing, to route the traffic to the correct container on the correct cluster node, and there is maybe a cache inolved or another thing making kept-alive sessions unaffected.
How could we precisely identify what is causing this 4s delay in establishing new http requests/sessions from containers allowing us to eventually identify potential changes to docker swarm configuration in order to remedy to this ?