High latency in urlfetch with google app engine

259 views Asked by At

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?

0

There are 0 answers