Google App Engine for Java的Performance性能问题
Google App Engine - Google Code,会根据负载情况自动关闭或者启动Java web应用的JVM,这使得很多http请求会触发启动JVM并部署web应用,因此这样的http请求非常慢,响应性能很差,用户体验非常差。因为大部分的应用还是需要连接DataStore,那么就需要初始化Data类的MetaData和连接数据库,不可避免需要很多时间。这个问题甚至Google自己也没有很好的办法。
Some requests run slower because App Engine needs to create a new Java virtual machine to service the request. We call that kind of request, a Loading Request. During a loading request, your application undergoes initialization (such as class loading, JIT compiling, etc) which causes the request to take longer. For slow requests which are already close to App Engine's request deadline, the extra initialization can push it past the deadline, causing a DeadlineExceededException. App Engine spins up JVMs on demand, so there are several reasons why you may receive a loading request: You can expect that during the course of developing your application, you will often experience the first two scenarios. In comparison, for a production app receiving even a very small but steady amount of traffic, loading requests are relatively infrequent. You can register an HttpSessionListener in your web.xml which logs from its sessionCreated method. For example: In the future, the Admin Console logs viewer will mark loading requests specifically so that they can be easily identified. App Engine provides high CPU warnings to help you determine which requests might need optimization. In the case of loading requests, though, the execution time is artificially longer due to the extra application initialization required. In addition, the number of loading requests is inversely proportional to the amount of traffic your application receives. So, while your CPU usage due to additional traffic will increase, your CPU usage due to loading requests will decrease. Here are a few suggestions: We've seen this request from some developers with low-traffic applications who'd like to reduce the percentage of loading requests they receive. Although we have many improvements in the pipeline to improve loading request performance, we'd like to gauge the general interest in this feature. If you'd like to be able to reserve a JVM at a price, please star this issue. If there's a particular pricing scheme you're interested in, let us know. We discourage developers from doing this because it increases the average number of loading requests for all low-traffic applications. Instead, we will continue to improve the performance of loading requests for everyone, and you can use the advice on this page to optimize your application's startup performance.What is a loading request?
What causes loading requests?
How do I distinguish normal requests from loading requests in my application logs?
// web.xml snippet
<listener>
<listener-class>
com.example.LogLoadingRequest
</listener-class>
</listener>
// LogLoadingRequest.java
public class LogLoadingRequest implements ServletContextListener {
private static final Logger logger = Logger.getLogger(LogLoadingRequest.class.getName());
public void contextInitialized(ServletContextEvent sce) {
logger.log(Level.INFO, "Loading request occuring.");
}
public void contextDestroyed(ServletContextEvent sce) {
}
}Do I need to be concerned about high CPU warnings in the admin console for my loading requests?
Given that, your time is most often better spent focusing on optimizing other high CPU warnings in relation to your application's total CPU usage.How can I speed up loading requests?
What is Google doing to speed up loading requests?
<precompilation-enabled>true</precompilation-enabled>
In the future, we plan to turn this optimization on for all applications.Can I pay to keep a JVM reserved for my application?
Should I run a cron job to keep my JVMs alive and reduce my loading requests?
Google App Engine 云计算的限制
Google App Engine - Google Code,虽然是个令人兴奋的东西,但是它由于种种原因有很多限制,而有些限制还是挺恼火的。
- 开发者对于App Engine的文件系统只拥有读的权限。
- App Engine仅可以在HTTP请求时执行代码(除了计划的后台任务、任务队列和XMPP服务)。
- 用户可以上传任意的Python模块,但它们必须是纯Python,不包括任何C扩展程序或其他必须编译的代码。
- App Engine限制每次Datastore请求最多返回1000行数据。
- Java应用程序只能使用JRE基本版本类库中的一个子集(JRE类白名单)。
- Java应用程序不能创建新的线程。
指标
限制
每个开发者拥有的应用程序
10
每次请求的时间
30秒
每个应用程序的文件
1000个
HTTP响应大小
10 MB
Datastore大小
1 MB
应用程序代码大小
150 MB
According to TLD or attribute directive in tag file, attribute value does not accept any expressions
Google App Engine for java时出这个错,只需要将web.xml里修改为:
<web-app xmlns="http://java.sun.com/xml/ns/javaee" version="2.5">