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

high cpu usage #40

Closed
thecodeassassin opened this issue Jul 22, 2016 · 6 comments
Closed

high cpu usage #40

thecodeassassin opened this issue Jul 22, 2016 · 6 comments

Comments

@thecodeassassin
Copy link

i start the sql proxy using the following command:

exec cloud_sql_proxy -dir=/cloudsql -instances=project:database

When the website is loaded the CPU usage of the proxy rises exponentially. Is there any way around this?

@thecodeassassin
Copy link
Author

does anybody know anything about this? The high cpu usage causes this to be unable in production.

@Carrotman42
Copy link
Contributor

Carrotman42 commented Jul 24, 2016 via email

@Carrotman42
Copy link
Contributor

Carrotman42 commented Jul 25, 2016

If you're willing to do the legwork to identify the hotspots of your code, you can read through this post about adding pprof to any Go program to automatically profile CPU (and memory) usage. The post is relatively long, but the part you're interested in are adding these lines to func main:

    f, err := os.Create("some-path-to-a-file-you-own.prof")
    if err != nil {
        log.Fatal(err)
    }
    pprof.StartCPUProfile(f)
    defer pprof.StopCPUProfile()

After recompiling the proxy and running it in a scenario where it has encountered the high CPU, kill the proxy process and look through data given by the pprof tool:

go tool pprof the-locally-compiled-proxy-executable some-path-to-a-file-you-own.prof

There's a few simple commands to look through the data (top10 or web for example), but if you don't have time to look through the data, feel free to email the profile output (some-path-to-a-file-you-own.prof) to cloud-sql@google.com and I'll try to interpret what's going on.

@Carrotman42
Copy link
Contributor

Please let me know if there's anything you've found related to this problem. I've not heard about this being a problem so I'm going to optimistically close this. Please reopen it if you are still having a problem.

@iftachsc
Copy link

+1 we have high cpu in GKE and most of the usage is from cloud sql proxy from no reason that make sense

@Carrotman42
Copy link
Contributor

Carrotman42 commented Oct 18, 2018 via email

yosatak pushed a commit to yosatak/cloud-sql-proxy that referenced this issue Feb 26, 2023
Set application environment variables to production by default
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