3

I have a python flask application running inside a docker container. And I am using Test-DbaNetworkLatency to test the network latency between my application and SQL Server (running on premise). I found that the network latency is very slow when it runs from a docker container but it is very fast when I run on a Mac host. The docker container is based on ubuntu and I installed powershell on it. Test-DbaNetworkLatency is running from powershell. I also installed powershell on my local Mac OS.

The result from my local is:

ExecutionCount     : 1
Total              : 220.91 ms
Average            : 220.91 ms
ExecuteOnlyTotal   : 154.21 ms
ExecuteOnlyAverage : 154.21 ms
NetworkOnlyTotal   : 66.69 ms

but the result from the docker container is:

ExecutionCount     : 1
Total              : 1.23 s
Average            : 1.23 s
ExecuteOnlyTotal   : 282.52 ms
ExecuteOnlyAverage : 282.52 ms
NetworkOnlyTotal   : 946.88 ms

You can see that there is a big network latency when it runs from docker. Is there anything wrong related to docker?

There is not much different if I ping the instance from container and local. But I do see performance different when a sql query is sent from container and local. That's why I need Test-DbaNetworkLatency to test network latency.

After some testing I found if I put the command Test-DbaNetworkLatency inside pwsh -Command "Test-DbaNetworkLatency ... " it will be very slow. But if I run pwsh to switch to powershell command then it runs as fast as my local. But how can I define a dockerfile to let the container initialize a powershell let me specify a powershell script as ENTRYPOINT?

Joey Yi Zhao
  • 37,514
  • 71
  • 268
  • 523
  • It could be an issue with the linux powershell, which has [significant performance issues](https://github.com/PowerShell/PowerShell/issues/1954). To exclude powershell as a suspect, could you try a ping to the server from host and the container and see if there is any significant difference? – Jay Oct 08 '19 at 01:57
  • pint host doesn't make any different. But the query I sent to sql server gives me different performance that's why I want to use `Test-DbaNetworkLatency` to test network latency. – Joey Yi Zhao Oct 08 '19 at 02:55
  • This link `significant performance issues` only tells initialization is slow. My command is running after power-shell initialised. – Joey Yi Zhao Oct 08 '19 at 03:05
  • Does this answer your question? [Slow DNS resolution inside docker container](https://stackoverflow.com/questions/41821857/slow-dns-resolution-inside-docker-container) – ti7 May 11 '21 at 19:25

0 Answers0