Search code examples
google-cloud-platformgoogle-kubernetes-enginestackdrivergoogle-cloud-stackdriver

How to use StackDriver on GCP to get how long does it take to process a request


I need to to understand how long does it take for a Python application hosted on top of Google Kubernetes Engine to handle a given request.

How can I can get and debug this value? Should I use StackDriver Profiler or configure StackDriver Trace? It's not clear to me which tool I should configure in order to get this info in the right way from StackDriver.


Solution

  • Cloud Trace tells you how long it takes an application to handle a given request. Cloud Trace collects latency data from App Engine, HTTP(S) load balancers, and applications instrumented with the Cloud Trace API, it can help you answer the following questions:

    • How long does it take my application to handle a given request?
    • Why is it taking my application so long to handle a request?
    • Why do some of my requests take longer than others?

    Cloud Trace is a distributed tracing system that collects latency data from your applications and displays it in the Google Cloud Console. You can track how requests propagate through your application and receive detailed near real-time performance insights, how long it takes your application to handle incoming requests from users or other applications, and how long it takes to complete operations like RPC calls performed when handling the requests. Cloud Trace automatically analyzes all your application's traces to generate in-depth latency reports to surface performance degradations, and can capture traces from all your VMs, containers, or App Engine projects. Once you’ve determined which requests might need to be optimized, you can use Cloud Profiler to see which parts of the code for those requests are using the most CPU and memory.

    Analysis reports show you the latency distribution for your application and also attempt to identify performance bottlenecks, which is a great feature. You have to have at least 100 traces before you can run a report, though.

    • To view traces, in the Google Cloud Console select Trace and then select Trace list. If you're using Trace for the first time, it can take a few minutes for traces to appear.
    • The Trace list page defaults to displaying data from the previous hour, you can change this interval. The graph labeled Select a trace displays a dot for each request in your selected time interval. The (x,y) coordinates for a request correspond to the time and latency of the request.
    • You can also use filters to find individual traces. Traces that don't match the filter are hidden from view. Each filter is specified by a predefined OPTION that is paired with a VALUE. The general syntax is: [OPTION] : [VALUE].

    Refer Finding and viewing traces for information.