Pre-application latency with AppEngine

Skip to first unread message

Prateek Malhotra

Nov 20, 2019, 10:06:54 AM11/20/19
to google-appengine-go
I've tested this on both Go 1.12 and Go 1.13: I added tracing to my application and noticed a lag between when AppEngine reports receiving the request and when my application registers receiving the request. In order to eliminate any of my middlewares/setup process as the culprit, I made a barebones handler to test the latency (code found below) and notice anywhere between a ~30-90ms lag time from when AppEngine starts the trace until my application registers the request. This is after I let it "warm" up first with 10 requests.

in Go 1.12:
Browser TTFB: 112.69ms
StackDriver Trace Output:
@0 ms (HTTP load balancer )
Traced time 62.974 ms
Untraced time 46.026 ms
@18.913 ms (AppEngine Entry)
Traced time 0.073 ms
Untraced time 62.901 ms
@50.164 ms (My Application)

in Go 1.13:
Browser TTFB: 62.19ms
StackDriver Trace Output:
@0 ms (HTTP load balancer )
Traced time 21.039 ms
Untraced time 41.961 ms
@18.053 ms (AppEngine Entry)
Traced time 0.066 ms
Untraced time 20.973 ms
@38.181 ms (My Application)

This feels higher than it should but I was curious if this is expected?

runtime: go112 # or go113
service: latency

module main

go 1.12

require (

package main

import (


func main() {
ctx := context.Background()

exp, err := stackdriver.NewExporter(stackdriver.Options{
Context:   ctx,
ProjectID: os.Getenv("GOOGLE_CLOUD_PROJECT"),

if err != nil {

http.HandleFunc("/", indexHandler)

h := TraceHandler(http.DefaultServeMux)

port := os.Getenv("PORT")
if port == "" {
port = "8080"
log.Printf("Defaulting to port %s", port)

log.Printf("Listening on port %s", port)

if err := http.ListenAndServe(":"+port, h); err != nil {

// TraceHandler sets up OpenCensus middleware for tracing and stats
func TraceHandler(h http.Handler) http.Handler {
return &ochttp.Handler{
Handler:          h,
Propagation:      &propagation.HTTPFormat{},
IsPublicEndpoint: false,

func indexHandler(w http.ResponseWriter, r *http.Request) {
if r.URL.Path != "/" {
http.NotFound(w, r)

fmt.Fprint(w, "Hello, World!")

Thank you,

Reply all
Reply to author
0 new messages