Is there a limit on the number of concurrent connections from Google engine to external services?

We have a java7 based google engine app. For some of our reporting processes, we already use an external service in AWS. This external service is spring based and is deployed on tomcat7 instance.

We consume this external REST API from gae app and get output from it. We recently needed to parallelize the task of generating a report using URLFetch.

I am initiating my 12 POST requests at the same time and then trying to collect the results using URLFetch. (I am using the same external service url for all requests)

But tomcat only receives 2 requests at the same time and this creates a bottleneck for us.

What can be limited by tomcat so it can only handle 2 requests at a time?

  • Is there anything to configure for spring in an external service?
  • Is there anything that needs to be configured for tomcat?
  • Is there anything that can be customized in Google App Engine?

You can find your request here and put together a piece of code for your reference.

URLFetchService fetcher = URLFetchServiceFactory.getURLFetchService();
        FetchOptions fetchOptions = FetchOptions.Builder.withDefaults();
        fetchOptions.doNotValidateCertificate();
        fetchOptions.setDeadline(60d);

    /* Initiate requests */
    ArrayList<Future<HTTPResponse>> asyncResponses = new ArrayList<Future<HTTPResponse>>();
    for(int i=startPage;i<(endPage+1);i++){
        /* Create list of parameters to pass wkhtmltoPDF */
        Map<String, Object> map = new HashMap<String, Object>();
        map.put("parameters", parameters);
        targetUrl = referer + "?viewMode=export&subjectId="+ subjectId +"&page=" + i;
        map.put("targetUrl", targetUrl);
        Gson gson = new Gson(); 
        String data = gson.toJson(map);
        URL serviceUrl = new URL(EXS_SERVER_URL+"/wkhtmltopdf");
        HTTPRequest request = new HTTPRequest(serviceUrl, HTTPMethod.POST, fetchOptions);  
        HTTPHeader header = new HTTPHeader("Content-Type", "application/json; charset=UTF-8");
        request.setHeader(header);
        request.setPayload(data.getBytes("UTF-8"));

        Future<HTTPResponse> responseFuture = fetcher.fetchAsync(request);
        asyncResponses.add(responseFuture);
    }

    /* collect responses */
    ArrayList<Integer> responseCodes = new ArrayList<Integer>();
    for(int i=0;i<asyncResponses.size();i++){
        Future<HTTPResponse> serviceResponse = null;
        try {
            serviceResponse = asyncResponses.get(i);
            int responseCode = serviceResponse.get(59, TimeUnit.SECONDS).getResponseCode();
            responseCodes.add(responseCode);
            byte[] pdfBuffer = serviceResponse.get(59, TimeUnit.SECONDS).getContent();
            if (pdfBuffer != null){
                PdfReader page = new PdfReader(pdfBuffer);
                copy.addDocument(page);             
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

      

+3
java spring google-app-engine tomcat


source to share


No one has answered this question yet

Check out similar questions:

356
What is the difference between Google App Engine and Google Compute Engine?
231
How do I use Google App Engine with my own bare domain (not a subdomain)?
161
Choosing Java vs Python in Google App Engine
125
Reviews on using Google App Engine?
117
Project structure for Google App Engine
116
How do I delete all datastores in Google App Engine?
91
Removing the Google App Engine app
76
Google app or Amazon web services
0
Parallelism in Google app
-1
What is Google App Engine concurrent connection limitation / how does it scale?



All Articles
Loading...
X
Show
Funny
Dev
Pics