Struts2, Springmvc, Servlet (JSP) performance comparison test

Source: Internet
Author: User
Tags name server lookup

Struts2, Springmvc, Servlet (JSP) performance comparison test.

The performance of the servlet should be the best, and it can be used as a reference, and the other tests should be on par with it.

As a programmer, for the performance of each framework to have a basic understanding, easy to choose the right decision to make.

Don't yell when you find anything in the test, because these are the basics of Java programmers. Everyone needs to know.

---------------------------------------------------------------------------------------

First read "Do you want to build a website that can withstand 5 million pv/a day?" Article to understand some of the basic concepts of testing. There is a good and bad performance standard before the test starts. Then use this standard to test your program.

---------------------------------------------------------------------------------------
Test Environment Description:
Server: 4G memory, Xeon 3.0 (4-core Hyper-threading) Cpu,windows 2003
Test machine: Notebook 2G memory, p8600 dual core cpu,windows XP
Network: 100Mb LAN
Test software:
Jmeter 2.3.4 Allocated 512M of memory
Tomcat 6 Default Memory size

---------------------------------------------------------------------------------------
test configuration such as: in fact, JMeter is still very weak, I open "Meeting point (synchronizing Timer)", "look at the result tree", "View results with a table" Will cause performance degradation in the test results and an error in response to a small number of requests (probably too many threads), so it is disabled. Only the cookie manager is enabled.


---------------------------------------------------------------------------------------
Tomcat6.0 the description of the configuration file, before doing the test is to complete the clear.
The default server.xml is as follows

XML code
    1. <connector port= "8080" maxhttpheadersize= "8192"
    2. maxthreads= "minsparethreads=" maxsparethreads= "75"
    3. Enablelookups= "false" redirectport= "8443" acceptcount= "100"
    4. connectiontimeout= "20000" disableuploadtimeout= "true"/>


enablelookups
Whether to allow DNS queries when the Web application is being converted to an IP address through the name server lookup machine name. DNS queries will be used, requiring network usage, longer
MaxThreads
Tomcat can create the maximum number of threads, each request needs a thread to handle, the original 150 is too small, we test the concurrency will exceed his.
Acceptcount
Specifies the number of requests that can be placed into the processing queue when all the threads that can be used to process the request are used, that is, the number of requests that are queued, and requests that exceed this number will reject the connection.
Connnectiontimeout
Network connection time-out, unit: milliseconds. Set to 0 to never time out, so the setting is hidden. It can usually be set to 20000 milliseconds.
minsparethreads
Number of threads created when Tomcat was initialized
maxsparethreads
Once the idle thread in the created thread exceeds this value, Tomcat shuts down the socket thread that is no longer needed.

Note: MaxThreads is set to 500, that is, Tomcat uses up to 500 threads to handle 500 concurrent (good server CPU, 500 no problem), do not wait for the situation to avoid the impact of test scores, for the following stress test ready.

The---------------------------------test started-------------------------------------------
Server CPU utilization at Test 10%
Test machine CPU Utilization 100% (test machine not ah, mainly jmeter performance, and eat memory, test machine p8600 dual-core CPU is very strong)
Every time the CPU is tested like this, it is unified here.

Test 1:jsp Page--2,213 Requests/sec
100 concurrent, Loop 100 times, a total of 10,000 requests, request a size 3.34KB JSP page.



Test 2:jsp Page--1889 Requests/sec
100 concurrent, 100 cycles, a total of 10,000 requests, request a servlet master controller, after verifying permissions (very simple), new action, and then forward to a size 3.34KB jsp page.



Test 3:html Page--2,607 Requests/sec
100 concurrent, looping 100 times, a total of 10,000 requests, request a 3.2KB HTML page.



Test 4:HTML page--833 Requests/sec
100 concurrent, looping 100 times, a total of 10,000 requests, request a 13.4KB HTML page. Compared with the above is just a large number of files, the network card ran full, Nic became a performance bottleneck, RPS down a lot!!



Test 5:Spring MVC2012 Requests/sec
100 concurrent, looping 100 times, a total of 10,000 requests, request a SPRING3 MVC action, and then forward to a 0.8K JSP, its content is simple HTML



Test 6:Spring MVC1800-1924 Requests/sec
100 concurrent, looping 100 times, a total of 10,000 requests, request a SPRING3 MVC action, two parameter types converted to int, Date, and then a new list, and then forward to a 1.3K JSP, with the JSTL tag to display the contents of the list.

Jstl label content is as follows, it seems Jstl label performance is good.

Java code
  1. <c:if test= "${empty list}" >
  2. <tr>
  3. <TD align= "center" > No record! </td>
  4. </tr>
  5. </c:if>
  6. <c:if test= "${not Empty list}" >
  7. <tr>
  8. <th> iteration count starting at 1 </th>
  9. <th> iteration count starting at 0 </th>
  10. <th> Product Name </th>
  11. </tr>
  12. <c:foreach items= "${list}" var= "item" varstatus= "S" >
  13. <tr bgcolor=${s.index%2==0? " #E2E2E2 ":" "}>
  14. <TD align= "center" >${s.count}&nbsp;</td>
  15. <TD align= "center" >${s.index}&nbsp;</td>
  16. <TD align= "center" >${item}&nbsp;</td>
  17. </tr>
  18. </c:forEach>
  19. </c:if>


Test 7:   access a picture (Srping way One) 1997 Requests/sec
100 concurrent, looping 100 times, a total of 10,000 requests. Because I used spring3 MVC, intercept/, so the picture cannot be accessed, so added:

XML code
    1. <servlet-mapping>
    2. <servlet-name>default</servlet-name>
    3. <url-pattern>*.jpg</url-pattern>
    4. </servlet-mapping>


Go to the default servlet to access the 2.5K picture



Test 8: Access a picture (Srping Way II) 1967 Requests/sec
100 concurrent, looping 100 times, a total of 10,000 requests, because I used the spring3 MVC, intercept/, so the picture can not be accessed, so added:
<mvc:resources mapping= "/images/**" location= "/images/" cache-period= "31556926"/>
To access the 2.5K picture, a spring-matched interceptor will be gone.


Test 9:struts2 using an official sample program(Struts2 tags are used)Dozens of requests/sec
100 concurrent, 1 cycles, no loops 100 times, because STRTUS2 in this test response is too slow, I can't afford to wait, so a single URL test sample from 10000 to 100. Altogether 11 URLs, total 1100 samples.
"Spring" uses the URL of the previous "Test 5", which is placed here for comparison with Strtus2.
"HTML" uses the URL of the previous "Test 3", which is placed here for comparison with Strtus2.
"Struts2-1" is using the official own sample project, the name is Struts2-blank-2.1.8.1.war
"Struts2-2" is using the official own sample project, the name is Struts2-showcase-2.1.8.1.war, I randomly selected an action to do the test
"Struts2-3" Ibid.
"Struts2-4" Ibid.
"Struts2-5" Ibid.
"Struts2-6" Ibid.
"Struts2-7" Ibid.
"Struts2-8" Ibid.
"Struts2-9" Ibid.
Do not optimize Struts2, use is the official belt of the example, STRUTS2 test results are not ideal, put here for a reference. "Struts2-1" is the STRUTS2 test score is the highest, but also not very ideal.



Test 10:struts2officially provided bySample Program (use Struts2 label--s:property)1192 Requests/sec
The last test turned out to be a terrible thing, and the next day, I thought about it and started to re-test it again, using the STRUTS2 officially provided Struts2-blank-2.1.8.1.war example.

To access the following action:http://192.168.0.5/struts2/example/helloworld.action, the action content is simply forwarded to a JSP.

is using the default action in the official example, I did not modify the result as

Here's what to say about the content that is forwarded to the JSP, which has the struts2 tag, as follows:

XML code
    1. <s:property value= "message"/>
    2. <s:url id= "url" action= "HelloWorld" >
    3. <s:param name= "Request_locale" >en</s:param>
    4. </s:url>
    5. <s:a href= "%{url}" >English</s:a>

Test 11:struts2 officially provided by Sample Program   (do not use Struts2 tags) 1976 Requests/second-excellent

I changed the contents of the JSP file in "Test 10", deleted all the struts2 tags, only output a line of text, test results such as:

God, performance is beyond my imagination, performance is too good to meet my requirements. It must have been the struts2 tag that dragged his hind legs.

Test 12:struts2 officially provided by Sample Program   (use Struts2 label--s:form) 426 Requests/sec
In order to let the phenomenon reappear, I put "Test 10" in the JSP and changed, JSP used other STRUTS2 tags, test results such as:

The tags used are:

XML code
    1. <s:form action= "Login" >
    2. <s:textfield key= "username"/>
    3. <s:password key= "Password"/>
    4. <s:submit/>
    5. </s:form>

=====================================================

Conclusion:

Struts2 frame performance is good, but Struts2 's label performance is too poor. To avoid using struts2 tags.
Struts2 due to the use of value stack, OGNL expression, struts2 tag library, etc., will lead to performance degradation, very serious decline. If you avoid or reduce the use of these, the performance is very good.
STRUTS2 multi-layer interceptors, multi-instance action performance are good, not the cause of performance problems.

Note: None of the above tests have a database or complex business, and the action and JSP content is simple enough to test the performance of the MVC section.

---------------------------------------------------------------------------------------
Other Test articles:
http://zhaoshg.iteye.com/blog/356231
http://www.iteye.com/topic/679543

MVC Framework Performance Comparison
Http://wenku.baidu.com/view/148d7e34eefdc8d376ee32ac.html

Comparison between SPRING3MVC and Struts2
http://www.iteye.com/topic/646240

---------------------------------------------------------------------------------------

Attached: Comparison of performance tests when parsing data with several tags and frame combinations

First, the data
Data through the query log table to obtain data, a total of 1302 data, the query data into a static list, to ensure the same data each request.
The elements of the test page are the same, but differ in the way data is taken.

Second, the test target
1, the performance of using STRUTS2 tag in JSP page;
2, the performance of using JSTL tag in JSP page;
3, the performance of the Freemarker page using the struts2 tag;
4, the performance of the Freemarker page using the JSTL tag;
5, the performance of the Freemarker page using its own data loading mode.

Three, loading time-consuming comparison
Time: Ms Note: Each comparison is performed in the same order in the same time period in the following ways

Struts2

JSTL (C)

Freemarker-struts2

Freemarker-c

Freemarker

First time

60S

58

1618

41

Second time

202

52

1643

39

Third time

211

58

2047

36

four times

196

49

1621

28

five times

218

52

1607

40

six times

303

331

1857

45

seven times

210

50

1671

33

Eighth time

311

51

1699

47

Nineth time

462

55

2180

37

Tenth time

218

46

1721

42

Average

263.7

80.2

1766.4

38.8

Remove the highest and lowest

223.75

53.125

1547.125

39.125

Struts2, Springmvc, Servlet (JSP) performance comparison test

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.