2019独角兽企业重金招聘Python工程师标准>>>
使用Jfinal一段时间了,记得当初14年吧,为了建立一个简单的门户网站,想找个轻量型的急速开发框架,然后搜到Jfinal,然后用了一段时间后,确实不错, 现在吧,随着时间的推移,作者对JFinal的版本迭代也是一直在努力,一直朝着优秀的方向走去;
这里做下对Jfinal的使用记录;
为什么要用Jfinal:
- 轻: 轻到什么程度呢, 体积小,框架仅339K,且无第三方依赖
- 快
- 开发快: 粘贴复制就是可以做到简单的模块增删改查;
- 启动快: 内置jetty启动,直接运行main方法就可以启动整个web项目
- 编译快: 热编译的支持,更是让jfianl使用者留下更多的时间陪家人
- 便捷
- 支持Validator后端校验
- AOP支持,拦截器配置灵活便捷
- Plugin体系结构,扩展性强,比如兼容spring定时器什么的也可以做到(当然,不推荐使用xml的方式)
- 无xml配置,框架接口简单明了
- 学习成本低,上手快,,这才是重点;节约更多的时间可以去陪恋人,家人
说了Jfinal的好处,那么Jfinal到底适合哪些应用场景呢,适合多大的运行项目呢;
适合中小型项目,这主要是针对一些业务处理不是很复杂的项目;
- 看表 200来张表 ,可以定位中型项目吧
- 看代码量 (未知)
- 物理大小 (未知)
看案例吧,具体说也难说, 看到的才最明了, 以下是Jfinal做的一些项目:
http://www.ysshow.com
http://www.666ys.cn
等等
关于性能及访问压力测试
- 100 个线程并发,20000次请求
ab -n 20000 -c 100 http://202.114.79.246:8280/portal/login?username=zhangsan\&password=123 This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking 202.114.79.246 (be patient) Completed 2000 requests Completed 4000 requests Completed 6000 requests Completed 8000 requests Completed 10000 requests Completed 12000 requests Completed 14000 requests Completed 16000 requests Completed 18000 requests Finished 20000 requestsServer Software: Apache-Coyote/1.1 Server Hostname: 202.114.79.246 Server Port: 8280Document Path: /portal/login?username=zhangsan&password=123 Document Length: 2412 bytesConcurrency Level: 100 Time taken for tests: 2.754403 seconds Complete requests: 20000 Failed requests: 0 Write errors: 0 Total transferred: 53053260 bytes HTML transferred: 48252060 bytes Requests per second: 7261.10 [#/sec] (mean) Time per request: 13.772 [ms] (mean) Time per request: 0.138 [ms] (mean, across all concurrent requests) Transfer rate: 18809.52 [Kbytes/sec] receivedConnection Times (ms)min mean[+/-sd] median max Connect: 0 1 2.0 2 9 Processing: 2 11 3.4 11 51 Waiting: 0 5 3.6 5 38 Total: 2 13 3.8 13 53Percentage of the requests served within a certain time (ms)50% 1366% 1475% 1580% 1590% 1795% 1898% 1999% 29100% 53 (longest request)
- 100 个线程并发,30000 次请求
ab -n 30000 -c 100 http://202.114.79.246:8280/portal/login?username=zhangsan\&password=123 This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking 202.114.79.246 (be patient) Completed 3000 requests Completed 6000 requests Completed 9000 requests Completed 12000 requests Completed 15000 requests Completed 18000 requests Completed 21000 requests Completed 24000 requests Completed 27000 requests Finished 30000 requestsServer Software: Apache-Coyote/1.1 Server Hostname: 202.114.79.246 Server Port: 8280Document Path: /portal/login?username=zhangsan&password=123 Document Length: 2412 bytesConcurrency Level: 100 Time taken for tests: 4.336593 seconds Complete requests: 30000 Failed requests: 0 Write errors: 0 Total transferred: 79581216 bytes HTML transferred: 72379296 bytes Requests per second: 6917.87 [#/sec] (mean) Time per request: 14.455 [ms] (mean) Time per request: 0.145 [ms] (mean, across all concurrent requests) Transfer rate: 17920.98 [Kbytes/sec] receivedConnection Times (ms)min mean[+/-sd] median max Connect: 0 2 1.8 2 10 Processing: 1 11 3.3 12 56 Waiting: 0 5 3.4 5 51 Total: 2 13 3.6 14 57Percentage of the requests served within a certain time (ms)50% 1466% 1575% 1580% 1690% 1795% 1898% 1999% 28100% 57 (longest request)
- 200 个线程并发,10 万次请求
ab -n 100000 -c 200 http://202.114.79.246:8280/portal/login?username=wangkai\&password=123 This is ApacheBench, Version 2.0.40-dev <$Revision: 1.146 $> apache-2.0 Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/ Copyright 2006 The Apache Software Foundation, http://www.apache.org/Benchmarking 202.114.79.246 (be patient) Completed 10000 requests Completed 20000 requests Completed 30000 requests Completed 40000 requests Completed 50000 requests Completed 60000 requests Completed 70000 requests Completed 80000 requests Completed 90000 requests Finished 100000 requestsServer Software: Apache-Coyote/1.1 Server Hostname: 202.114.79.246 Server Port: 8280Document Path: /portal/login?username=wangkai&password=123 Document Length: 2411 bytesConcurrency Level: 200 Time taken for tests: 15.194965 seconds Complete requests: 100000 Failed requests: 0 Write errors: 0 Total transferred: 265219295 bytes HTML transferred: 241208495 bytes Requests per second: 6581.13 [#/sec] (mean) Time per request: 30.390 [ms] (mean) Time per request: 0.152 [ms] (mean, across all concurrent requests) Transfer rate: 17045.32 [Kbytes/sec] receivedConnection Times (ms)min mean[+/-sd] median max Connect: 0 10 147.1 3 3019 Processing: 1 18 7.0 18 228 Waiting: 0 8 6.7 8 220 Total: 4 29 147.4 21 3047Percentage of the requests served within a certain time (ms)50% 2166% 2475% 2680% 2790% 3095% 3398% 3799% 43100% 3047 (longest request)
相对于 struts2 性能提升 8 倍左右,相对 spring 性能提升两倍多,只要服务器性能好并且没有数据库或其它瓶颈,并发 1000 以上不是问题;
不过,Jfinal只不过是你整个架构的一部分,并发访问量承受能力完全取决于你的整体架构如何;
官方并没有给出具体数据,以上数据类型是截至开源社区中的内容;
没有对比就没有伤害(Jfinal PK springMVC)
- 开发效率至少比spring快三倍以上(主要由于热编译,启动快,结构简单,无xml)
- Jfinal Db + Record模式,灵活便利 ,维护量少
- spring 本身就很厚重,在加上ser/get封装类,维护麻烦
- 同样是添加Validator后端校验,springMVC配置则要麻烦的多
- 更多的就需要你自己去体验了
以上对比是在开发中小型(业务不复杂)项目的时实际经验总结;