Hey ssmcookiemonster, When debugging latency of a request, it's best to only surround the request action itself with timing code, so you should profile the time to execute the following two lines only:
Future<HTTPResponse> future = fetcher.fetchAsync(url); HTTPResponse responseHttp = future.get(); This will minimize the impact of memory-management, object-creation, string-buffering, etc., and tend to show a more accurate measure of network latency. Another way to get insight into the problem is to ping / traceroute / mtr the target of your request from various locations. You might want to run these diagnostic tools from: * your local development box * a compute-engine instance in the same region as your app (US or EU) * other locations around the world This will allow you get a handle on how traffic will be routed to the endpoint you're attempting to reach, and the relative latencies from different locations. You may also want to run Url Fetch requests to locations that are closer to your app and/or development box and see how latency is affected. Finally, you can install AppStats (Java <https://cloud.google.com/appengine/docs/java/tools/appstats> | Python <https://cloud.google.com/appengine/docs/python/tools/appstats>) on your app to see the statistics around UrlFetch calls your app makes. I hope this information has provided a helpful guide to debugging latency with Url Fetch. On Wednesday, June 24, 2015 at 4:23:23 AM UTC-4, ssmcookiemons...@gmail.com wrote: > > We have a Java application that make use of urlfetch calling an external > api. We are having issues with the request time. When we do a request in a > local environment we have a mean time of 300ms, however in production we > have times of 1s or 1.4s. > > This is the code we are using: > > Calendar start = Calendar.getInstance(); > > try { > > URLFetchService fetcher = > URLFetchServiceFactory.getURLFetchService(); > > URL url = new URL( String.format( API_URL, productsIds ) ); > Future<HTTPResponse> future = fetcher.fetchAsync(url); > > > HTTPResponse responseHttp = future.get(); > byte[] content = responseHttp.getContent(); > > response = new String(content); > > System.out.println("request time :" + > (Calendar.getInstance().getTimeInMillis() - start.getTimeInMillis() ) ); > > > } catch ( Exception e ) { > LOGGER.log( Level.SEVERE, "Error calling api : " + e.getMessage() ); > } > > > Is Google doing any kind of validation that produces this time increase? > > Is there a way to reduce the request time? > > Thank you very much > > > > > > > > > -- You received this message because you are subscribed to the Google Groups "Google App Engine" group. To unsubscribe from this group and stop receiving emails from it, send an email to google-appengine+unsubscr...@googlegroups.com. To post to this group, send email to google-appengine@googlegroups.com. Visit this group at http://groups.google.com/group/google-appengine. To view this discussion on the web visit https://groups.google.com/d/msgid/google-appengine/3447916e-079b-4186-be6a-7a84fa99f1ea%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.