2015-05-05 168 views

回答

22

由於您的項目已經在tomcat 7上運行,我建議保持現狀一段時間。有關tomcat 8性能改進的數據不多。有些問題在互聯網上有報道,這是任何新產品發佈的常見問題。

Tomcat 8在併發環境中具有更好的性能。

根據我對tomcat產品的經驗,除非您有非常資源密集的應用程序,否則很可能升級不會導致任何顯着的性能。請閱讀下面的鏈接升級換代之前

http://events.linuxfoundation.org/sites/events/files/slides/2014-04-09-Migrating-to-Apache-Tomcat-8.pdf

重要變化

的Java 1.7 ==>第一個重要的變化是,Tomcat的8現在需要Java 7或更高版本才能運行,因此,如果你是從早期的Tomcat版本遷移,應該升級到Java 7

Specification Changes 

Servlet 3.1 (JSR 340) 
JSP 2.3 (JSR 245 maintenance release) 
EL 3.0 (JSR 341) 
WebSocket 1.0 (JSR 356) 

Specification Changes: EL 3.0 

Coercion of nulls to Number, Character or Boolean 
- EL 2.2 and earlier (0, 0, false) 
- EL 3.0 and later (null, null, null) 
System property 
– org.apache.el.parser.COERCE_TO_ZERO 
– Set to true for EL 2.2 behaviour 

Specification Changes: JSP 2.3 

Minor changes to reflect the changes in EL 3.0 
JSP 2.3 
– Supported: GET, POST and HEAD 
– Undefined: Everything else 
JSP 2.2 and earlier 
– Undefined: Most implementations assumed all 
Tomcat only permits GET, POST and HEAD 
– Protection against verb tampering 

Specification Changes: WebSocket 1.0 

Tomcat 7 initially shipped with a proprietary WebSocket API 
- Tomcat 8 ships with a JSR 356 WebSocket implementation 
– Also back-ported to Tomcat 7 
- The proprietary WebSocket API is deprecated in Tomcat 7 
- Applications using the proprietary API need to migrate 
– Relatively simple 
– https://svn.apache.org/r1424733 

Specification Changes: Servlet 3.1 

- Session ID changes by default on authentication 
– Prevents session fixation 

Tomcat Changes: 

Connectors 

Default connector has changed from BIO to NIO 
– BIO is likely to be dropped for Tomcat 9 
- Only BIO option not supported by NIO is irrelevant for NIO 
– disableKeepAlivePercentage 
- May notice different network/CPU loads 
– More established, idle connections 
– Marginally higher CPU load 

Static Resources 

Tomcat 7 
– Aliases 
– VirtualLoader 
– VirtualDirContext 
– JAR resources 
– External repositories 
- All variations on a theme 
- Each implemented differently 


Tomcat 8 
– New WebResources implementation 
▪ JAR resources 
– External resources for class loader 
- Completely new configuration 
- Caching attributes removed from Context 

Resources now defined by as: 
– Pre-resources 
– Main resources 
– JAR resources 
– Post-resources 

Resources attributes: 
– base 
– internalPath 
– webappMount 
– readOnly 

Internal APIs 

- Lots of changes 
– Manager, Loader and Resources are now Context only 
– Mapper moved from Connector to Service 
– WebResources 
- If you extend a Tomcat class, review the API docs 

Database Connection Pools 

- Tomcat 7 and earlier based on DBCP 1 
- Tomcat 8 based on DBCP 2 
- Better performance in concurrent environments 
– Comparable to Tomcat’s JDBC pool 
- There are some changes to configuration attributes 
– Reflect consistency changes made in Commons Pool 2 
- maxActive -> maxTotal 
- maxWait -> maxWaitMillis 
- Validation no longer requires a validation query 
– Uses Connection.isValid() 

服務器連接

就服務器連接器而言,默認的HTTP和AJP連接器實現已從Java阻塞IO實現(BIO)切換到Java非阻塞IO實現(NIO)。較舊的BIO可能仍然可以使用,但使用非阻塞IO的Servlet 3.1和WebSocket 1.0功能將回退到阻塞IO,這可能會導致意外的應用程序行爲。

Web應用程序資源

的資源元素是配置的一部分,代表所有可用的Web應用程序的資源進行了修訂。現在它包括類,JAR文件,HTML,JSP和任何其他有助於Web應用程序的文件。提供實現來使用目錄,JAR文件和WAR作爲這些資源的來源,並且可以擴展資源實現以提供對以其他形式存儲的文件(例如在數據庫或版本化存儲庫中)的支持。

遠程調試

當與JPDA選項啓動Tomcat 8啓用遠程調試,8 Tomcat的localhost上偵聽:8000在默認情況下。早期版本在*:8000上進行監聽。如果需要,可以通過在例如setenv。[bat | sh]中設置JPDA_ADDRESS環境變量來覆蓋此缺省值。

變化API

雖然Tomcat的8個內部API是廣泛兼容的Tomcat 7已經出現在詳細度的許多變化和它們不是二進制兼容的。與Tomcat內部交互的自定義​​組件的開發人員應該檢查相關API的JavaDoc。

特別值得注意的是:

經理,裝載機和資源從容器轉移到上下文語境,因爲只有使用它們的地方。

由於映射器對於給定服務的所有連接器都是相同的,因此映射器已從連接器移動到服務。

正如我們所說,有一個新的資源實現將別名,VirtualLoader,VirtualDirContext,JAR資源和外部存儲庫合併到一個框架中,而不是爲每個功能單獨配置。

提供有關在Tomcat中8的變化更多信息的某些鏈接給出低於Tomcat本身

http://people.apache.org/~markt/presentations/2013-09-Apache-Tomcat8.pdf

https://tomcat.apache.org/tomcat-8.0-doc/changelog.html

6

以下是自己何時升級的方法。現在,您可以使用Tomcat,任何版本的使用,或在將來,它不只是包括升級從Tomcat 7到Tomcat 8

大多數變化到Tomcat 當一個主要版本改變是升級構建特定版本的servlet,JSP和JDK規範。如果您的應用程序不需要更新的規範,並且您使用的版本沒有「歸檔」(本文撰寫時Tomcat 7未歸檔),則可能不需要升級。 http://tomcat.apache.org/whichversion.html涵蓋了如何進行選擇。

在現實世界的情況下,您的選擇也可能受其他因素的影響,例如您的製作發行版中包管理器是否支持您想要的版本。 或者相反,如果您的發行版僅包含特定版本的Tomcat,則可以升級,因爲它可以節省大量時間。

請記住,新功能還意味着可能出現新的錯誤。如果你沒有使用新的Tomcat版本的規格,你是否想冒一些破壞的機會?僅僅因爲某個版本具有更高性能的潛力並不意味着它不會在您的獨特部署環境中崩潰。如果你能負擔得起,最好的答案是在負載平衡器後部署兩個版本,以防新的版本無法正常工作。

也就是說,軟件總是有所改進。我建議您閱讀發行說明,瞭解您選擇的各種版本主要版本的發佈情況,以便根據自己的情況選擇最佳版本。例如,https://tomcat.apache.org/tomcat-8.0-doc/RELEASE-NOTES.txt涵蓋了8.0版本。

一旦你選擇了一個主版本,你一般都想使用它的最新版本,因爲隨着時間的推移bug會得到修復。

+0

不僅更加錯誤,而且在開發工具,例如「服務Eclipse中的「沒有發佈的模塊」功能在Tomcat 8中效果不佳。 – rustyx

2

查看下面tomcat 8的新特性。這將有助於決定是否遷移,如果你需要它們。

Tomcat 8.0版本與Java EE 7規範保持一致。它支持:

  • 它支持的Java Servlet 3.1
  • Java服務器頁(JSP)2.3
  • 爪哇統一表達式語言(EL)3.0
  • 爪哇WebSocket的1.0

Tomcat的8可以使用Apache便攜式運行時提供卓越的可伸縮性,性能以及與本機服務器技術的更好集成。

在服務器連接器而言,默認HTTP和AJP連接器實現已經從Java阻塞IO實現(BIO)到Java非阻塞IO實現(NIO)

另請注意,Tomcat的8切換需要Java 7或更高版本才能運行,因此只有在項目中至少使用Java 7時才能遷移。