1

I have followed all the configuration steps for my WarmupServlet in my app engine project and I see it run at startup, but still I see my first endpoint call as a loading request which takes up to 25 seconds which is absolutely unacceptable. I need to be able to warm up each endpoint individually so that there will be no loading requests. (Apparently just setting up a warmp-up servlet is not enough.) So, my question is, how can I call a method in endpoints so that the endpoint is properly warmed up to serve from my WarmupServlet? I tried below with no success:

MyEndpoint me = new MyEndpoint();
me.getMyEntity(1L);

where

@ApiMethod(name = "getMyEntity")
public MyEntity getMyEntity(@Named("id") Long id) {
    EntityManager mgr = getEntityManager();
    MyEntity myEntity = null;
    try {
        myEntity = mgr.find(MyEntity.class, id);
    } finally {
        mgr.close();
    }
    return myEntity;
}
doctorram
  • 1,112
  • 14
  • 13
  • which configuration steps did you follow for your warm up servlet? – Michael Meyer Mar 27 '17 at 09:18
  • @Michael https://cloud.google.com/appengine/docs/standard/java/warmup-requests/configuring – doctorram Mar 28 '17 at 14:23
  • are you running a frontend instance? – Michael Meyer Mar 28 '17 at 18:39
  • Yes with manual scaling – doctorram Mar 29 '17 at 02:52
  • maybe you can try to make a real http call to your endpoint and not only creating the object. e.g. https://my-app...../getMyEntity – Michael Meyer Mar 30 '17 at 08:05
  • Yeah, maybe the best way is to just send an http request from the backend to itself. Can you write a Java http code sample (say for getMyEntity) that works with the app engine endpoints and passes some different type parameters? I've only used them from Android with MyEndpoint.Builder. Please post it as an answer so that I can accept it. – doctorram Mar 31 '17 at 14:27

1 Answers1

0

After adding the client endpoints jar file as a library, this properly warms up MyEndpoint from the Java backend:

NetHttpTransport HTTP_TRANSPORT = GoogleNetHttpTransport.newTrustedTransport();
JsonFactory JSON_FACTORY = JacksonFactory.getDefaultInstance();

Myendpoint.Builder endpointBuilder = new Myendpoint.Builder(
          HTTP_TRANSPORT,
          JSON_FACTORY,
          null);

endpointBuilder.setApplicationName("My App");
Myendpoint endpoint = endpointBuilder.build();
endpoint.getMyEntity(1L).execute();
doctorram
  • 1,112
  • 14
  • 13