开发者

Spring MVC on GAE: Slow Load Time

I recently deployed a Spring MVC application to google app engine, and the intial load time is about 7sec. Once the application is loaded, the app is quite responsive. But, if the app is idle for more than 1 minute (there isn't ANY traffic to it) the app needs to be again reloaded by GAE, which, takes about 7sec as well. For a PRD-level application this is unacceptable. (The app is empty -- I'm not even using JPA, Sitemesh, Spring Security, etc yet. It just loads a jsp page with some text.)

The only "best practice" to fix开发者_运维技巧 the 'load time' I've seen so far is to set up a cron job that hits the url every minute, therefore keeping the app 'loaded'. Obviously this is a terrible solution.

So here is the question: Are there any "best practices" for Spring on GAE in terms of "responsiveness"? Since google and spring are working on developing better integration between the two of them, has there been any news/progress on this problem? I can't find anything concrete, that's why I'm asking it here

Topic Discussions: http://groups.google.com/group/google-appengine-java/browse_thread/thread/80d014fd5abd526f

UPDATE

There is a 'ticket' to create reserved instances, as well as 'heat up' logic: http://code.google.com/p/googleappengine/issues/detail?id=2456


Since SDK 1.4.0 you can avoid this latency using warmup requests.
Warmup requests load application code into a new instance before any live requests reach that instance.


GAE started to provide a paid-for service where you can have a hot instance reserved at all times:

http://googleappengine.blogspot.com/2010/12/happy-holidays-from-app-engine-team-140.html

Always On - For high-priority applications with low or variable traffic, you can now reserve instances via App Engine's Always On feature. Always On is a premium feature costing $9 per month which reserves three instances of your application, never turning them off, even if the application has no traffic. This mitigates the impact of loading requests on applications that have small or variable amounts of traffic.

In conjunction with warm-up requests, this is the best solution if you're planning on using GAE.


Ok, due to lack of responses I decided to go with the cron job (since I can't see any other option as of now)

Here is the cron.xml file I'm using

<?xml version="1.0" encoding="UTF-8"?>
<cronentries>
  <cron>
    <url>/keepalive</url>
    <description>Keep the application alive</description>
    <schedule>every 1 minutes</schedule>
  </cron>
</cronentries>

And here's the controller:


package com.xxxxxxxxxxxxx.web;

import org.slf4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;


@Controller
@RequestMapping("/keepalive")
public class KeepAliveController {

    private Logger logger = org.slf4j.LoggerFactory.getLogger(KeepAliveController.class);

    @RequestMapping(method = RequestMethod.GET)
    public void keepAlive() {
        logger.info("I'm alive!");
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜