我在GAE上運行的Java Web應用程序。我使用Spring進行servlet調度。我使用它,以便我可以使用批註來定義我的servlet中的調用,以便它執行所有參數分析和結果轉換。網絡應用程序在GAE中的加載時間約爲10秒,我想知道是否有辦法縮短這個時間。謝謝。提高GoogleAppEngine Spring的web應用程序的啓動時間
這裏是我的web.xml
<?xml version="1.0" encoding="utf-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" version="2.5">
<servlet>
<servlet-name>mvc-dispatcher</servlet-name>
<servlet-class>
org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>publisher-servlet</servlet-name>
<servlet-class>
com.example.webapp.PublisherServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>mvc-dispatcher</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>publisher-servlet</servlet-name>
<url-pattern>/publisher</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/mvc-dispatcher-servlet.xml</param-value>
</context-param>
<context-param>
<param-name>contextClass</param-name>
<param-value>com.example.webapp.CustomXmlWebApplicationContext</param-value>
</context-param>
和我的MVC-調度-servlet.xml中
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:util="http://www.springframework.org/schema/util" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd">
<mvc:annotation-driven />
<bean class="com.y2apps.quoteformessenger.webapp.ClientController">
</bean>
這裏是第一個呼叫的服務器日誌這將啓動服務器
I 2015-10-13 14:19:54.937 200 119.69 KB 10.98 s I 14:19:59.222 I 14:20:05.916 /getallcategorylists?typeId=2
84.229.82.245 - - [13/Oct/2015:04:19:54 -0700] "GET /getallcategorylists?typeId=2 HTTP/1.1" 200 122562 - "okhttp/2.2.0" "iron-core-93812.appspot.com" ms=10978 cpu_ms=13017 cpm_usd=0.01369737 instance=00c61b117c057f572d9967e34ef8e65bb7cbfdcd app_engine_release=1.9.27 trace_id=-
I 14:19:59.222 javax.servlet.ServletContext log: Initializing Spring FrameworkServlet 'mvc-dispatcher'
I 14:20:05.916 This request caused a new process to be started for your application, and thus caused your application code to be loaded for the first time. This request may thus take longer and use more CPU than a typical request for your application.
你有沒有考慮一個[預熱請求(https://cloud.google.com/appengine/docs/java/config/appconfig?hl=en#Java_Warmup_requests)?它不會縮短加載時間,但會隱藏它:「在任何活動請求到達該實例之前,熱身請求會將應用程序代碼加載到新實例中。」 –
假設你也有一個'COntextLoaderListener'停止兩次加載你的bean。 –
啓動在App Engine上需要依賴於運氣/負載和彈簧一會兒本身不是最快的兩種,特別是如果你把它做很多類似的類路徑掃描AUTOMAGIC事情。動力越差,它應該得到的越快。你可以在本地測試。 – zapl