~20ms latency between two servlets, same project, is that about right?

53 views
Skip to first unread message

Eric Hubbard

unread,
Aug 26, 2017, 7:52:22 PM8/26/17
to Google App Engine
Playing around with splitting my project up into separate services, and invoking via URLFetch between them.  I'm seeing anywhere from a 20-22ms latency on a very basic remote side side.  I'm using Kotlin compiled down to java8.....   (the ping servlet is in java8...)...     

So.. does ~20ms seem about right? 



val fetchOptions =FetchOptions.Builder.doNotFollowRedirects()
val instanceHostname =getInstanceHostname("default", "1", "$serverNum")
val u = URL("http://$instanceHostname/ping")
val req = HTTPRequest(u, HTTPMethod.GET, fetchOptions)
val timer = Stopwatch.createStarted()
val fetch = urlFetchService.fetch(req)
val rc = fetch.responseCode
timer.stop()

and then this in the /ping servlet

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter writer = response.getWriter();
writer.println("Hello there from the backend");
writer.flush();
}

Jordan (Cloud Platform Support)

unread,
Aug 29, 2017, 2:03:46 PM8/29/17
to google-a...@googlegroups.com
It really depends on if you are making calls within App Engine Standard or App Engine Flexible as they both send/accept requests using different infrastructures. 

- The App Engine Standard URLFetch infrastructure typically adds less than 1 ms latency overhead to HTTP requests. For URLFetch requests to other App Engine Standard services, I am seeing worst case ~8ms of latency in the 95th percentile (meaning 95 percent of URLFetch requests are under 8ms). Note that we do not guarantee any specific SLA on latency.

- The App Engine Flexible environment uses Compute Engine virtual machines that are behind their own gateway. I am seeing ~20ms serving latency for Flex apps in the US at the 99th percentile (meaning 99 percent of requests are under 20ms).

There are many factors in App Engine that can be slowing down your ping, such as instance startup time (based on your code and runtime), scaling settings, and instance class. Also your actual coding language adds to the ping time while it accepts/processes/and returns the request. Therefore, to get a more accurate ping for only the service-to-service communication time, you should do it by looking at the actual time your App Engine service accepted the request in the Logs Viewer. It is also recommended to turn off redirects for requests to internal services. 

Eric Hubbard

unread,
Aug 29, 2017, 3:14:39 PM8/29/17
to google-a...@googlegroups.com
Thanks for the great info!

I'm running standard and java8.  My latency times were much lower 24 hours later.  I went from a chaotic..20-50ms...   down to a very stable ~12ms 24 hours later.  Maybe some  environmental things were going at at the time.  These numbers were reported by my code, and also seen by the log traces.  



--
You received this message because you are subscribed to a topic in the Google Groups "Google App Engine" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-appengine/2vx4_sdC8v0/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-appengine+unsubscribe@googlegroups.com.
To post to this group, send email to google-appengine@googlegroups.com.
Visit this group at https://groups.google.com/group/google-appengine.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/b0335619-c20c-4938-9994-76549c75f009%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages