spring-petclinic性能調優實戰(轉)


1.spring-petclinic介紹 
spring-petclinic是spring官方做的一個寵物商店,結合了spring和其他一些框架的最佳實踐。 

架構如下: 
1)前端 
Thymeleaf做HTML模板引擎或純JSP加Tag 
CSS采用Bootstrap 
webjars用來管理客戶端依賴 
Dandelion做表格 

2)后端 
Controller,用Spring MVC, Bean Validation 
Service, 用Spring事務,加上ehcache緩存 
Repository,寫了3套,spring data jpa, jpa, jdbc,供大家自由選擇 
異常處理,統一交給SimpleMappingExceptionResolver處理,導向一個頁面exception.jsp 


2.性能調優 
有專家對這個示例做了一些性能調優實戰,使得性能從285 req/sec提升到了1225 req/sec。 

性能調優實戰一共分5天,對應5篇文章。 

第1天,搭建jmeter測試環境,寫jmeter腳本,測試一開始的性能是285 req/sec 
第2天,用yourkit剖析問題,抓出元凶Dandelion,並解決性能問題,性能提升到560 req/sec。 
隨后去session化,性能變為532 req/sec。 
再使用tomcat新的NIO connector,性能提升到867 req/sec 
第3天,找到Commons DBCP乃又一元凶,改用tomcat dbcp,性能提升到910 req/sec。 
Webjars也有損性能,所以去掉,性能提升到942 req/sec 
去掉人為的monitoring AOP,性能提升到959 req/sec 
第4天,測試發現spring data jpa, jpa, jdbc三種性能差別不大。 
使用延遲加載和Open Session In View(要小心,有陷阱),性能提升到1066 req/sec 
第5天,增加一個cache,用來緩存JpaOwnerRepositoryImpl.findByLastName(),性能提升到1225 req/sec 

3.鏈接 
官方原版petclinic 
專家優化版petclinic 

5篇優化文章,對應5天優化歷程 
Improving the performance of the Spring-Petclinic sample application (part 1 of 5) 
Improving the performance of the Spring-Petclinic sample application (part 2 of 5) 
Improving the performance of the Spring-Petclinic sample application (part 3 of 5) 
Improving the performance of the Spring-Petclinic sample application (part 4 of 5) 
Improving the performance of the Spring-Petclinic sample application (part 5 of 5) 

 

原文鏈接:https://xpenxpen.iteye.com/blog/2146465


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM