Improve accuracy of application start up time in docker
Today it's impossible to compare application start-up time between docker and non-docker hosted apps. The docker-hosted startup time includes the time to start the container.
For example, comparing a .NET app to a go app in docker:
I'm pretty sure the go app should start faster than the .NET app, but the current numbers indicate the reverse.
Is there a way to make these app types more comparable?
One idea: write to the console as we do with ready-state text. The docker container could use CMD + bash to write to the console to indicate that the docker container has finished starting, then launch the docker-hosted app. Crank uses that console write to remove the docker container start time from the app startup time.
When I was measuring startup times, I used docker inspect --format='{{.State.StartedAt}}' to get the start time of the container. Then I would subtract off the timestamp of when the app "started" to get the start up time of the app.
For a Go app using gin (not grpc) the startup times I was observing were in the 5ms range using this measurement technique.
I believe the main issue is that gin doesn't output anything and we can only know when it has started by polling the http endpoint.
Assuming docker is out of the picture, how would we measure the startup time of "this" app?
On a side note I agree with the suggestion of using the .State.StartedAt property, but it might be easier to keep what the current code is doing and split docker run into docker create and docker start and only measure the time it takes for docker start. This doesn't solve the gin problem though which is we need to poll right now.
I believe the main issue is that gin doesn't output anything and we can only know when it has started by polling the http endpoint.
Yeah, :(. What I did is updated gin to print out a message right before it starts listening.
When I was measuring startup times, I used
docker inspect --format='{{.State.StartedAt}}'to get the start time of the container. Then I would subtract off the timestamp of when the app "started" to get the start up time of the app.For a Go app using
gin(not grpc) the startup times I was observing were in the5msrange using this measurement technique.
That sounds like a good solution. It can be automatically applied to docker startup measurement in crank.
I'd rather update the TE benchmark to output the message when the application is ready. log is available, I think it could be called before this line https://github.com/TechEmpower/FrameworkBenchmarks/blob/master/frameworks/Go/gin/gin-std/main.go#L156
Will submit a PR.