简体   繁体   中英

Very slow performance with a free google app engine java

I started an app with angularJs in front end and google app engine java for rest services in backend. All works, but my app have only my traffic. So each time i don't send request for a while, my app can take more than 30 sec to answer me...

Im not the only one to have this problem with java app on gae. I found two solutions on internet :

  • create on gae new instances, but it won't be free...
  • config the warmup requests.

So i customize web.xml with this :

  <servlet-mapping>
    <url-pattern>/_ah/start</url-pattern>
    <servlet-name>startup</servlet-name>
  </servlet-mapping>

  <servlet>
    <servlet-name>startup</servlet-name>
    <servlet-class>fr.gae.todo.api.servlet.StartupServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>

and appengine-web.xml with this :

<warmup-requests-enabled>true</warmup-requests-enabled>

but my StartupServlet never log anything... Does anybody know why ?

Or a solution with loading request ? Because i can see them in log

Yes, I can understand the confusion...

In App Engine a warmup request isn't what you think it is intuitively. It doesn't warm_up an instance and then send the request if no instances are available. What it actually does is anticipate peak traffic when all your instances are occupied; it will then warm-up a few instances in case more requests are coming in.

Keep in mind that the instance loading time cannot be magically shortened, so when you have no active instances, the first request WILL take X amount of time to be served, warmup or not.

If you need 30 seconds to load, you can tell the instance to "warmup" for 30 seconds and then send the request which is immediately processed (30 seconds total) OR you can simply send the request and it loads the instance (loading_request) and the take 30 seconds to process your request (30 seconds total). You see what I mean? That's why warmup request are not implemented when none of your instances are up, it's pointless.

For details, read this article - https://cloud.google.com/appengine/docs/adminconsole/instances#Warmup_Requests

===---===

The solution is as you mentioned... Always keep an instance alive and idling, that will work.

Thank you LiY ! I finally choose another solution that seems to work very well. I have created a free account on uptimerobot.com with a job that request one of my REST service every 25min. In this way, my instance is still up with a good response time.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM