Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve accuracy of application start up time in docker #559

Open
JamesNK opened this issue Mar 7, 2023 · 5 comments
Open

Improve accuracy of application start up time in docker #559

JamesNK opened this issue Mar 7, 2023 · 5 comments

Comments

@JamesNK
Copy link
Member

JamesNK commented Mar 7, 2023

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:
image
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.

@eerhardt
Copy link
Member

eerhardt commented Mar 7, 2023

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.

@sebastienros
Copy link
Member

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.

@eerhardt
Copy link
Member

eerhardt commented Mar 7, 2023

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.

@JamesNK
Copy link
Member Author

JamesNK commented Mar 8, 2023

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.

That sounds like a good solution. It can be automatically applied to docker startup measurement in crank.

@sebastienros
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants