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)

猜你喜欢

转载自xpenxpen.iteye.com/blog/2146465