I am working on migrating a project from (JSF 1.2, Richfaces 3.3.4 running on JBoss 4.2.3) to (JSF 2.2, Richfaces 4.5 running on Wildfly 8.1.0). After partially migrating some views I found that the performance of the application using JSF 2 is terrible.
I noticed this issue when an ajax request is sent, JSF 2 is rendering the whole view although the render attribute is pointing to one outputText
Example (Can be downloaded from HERE)
In my example I will use the same code sample for both JSF 1.2 and 2.2. Afterwards I will click on the ajax button multiple times and measure the response time for each request using chrome inspection tool.
Given the following index1.XHTML using JSF 1.2 and Richfaces 3.3.4
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a="http://richfaces.org/a4j">
<head>
</head>
<body id="body">
<!-- Later the outputText elements below will be included here-->
<h:form>
<a:commandButton value="TestBtn" reRender="output"/>
</h:form>
<h:outputText value="test" id="output"/>
</body>
</html>
Clicking on "TestBtn" multiple times, the average time is 15ms:
Given the following index2.XHTML using JSF 2.2 and Richfaces 4.5.0
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:a="http://richfaces.org/a4j">
<h:head>
</h:head>
<h:body id="body">
<!-- Later the outputText elements below will be included here-->
<h:form>
<a:commandButton value="TestBtn" render="output"/>
</h:form>
<h:outputText value="test" id="output"/>
</h:body>
</html>
Clicking on "TestBtn" multiple times, the average time is 18ms:
Well, so far so good. Now the performance issue comes when I add the following outputText elements
<h:outputText value="testingElement"/>
<h:outputText value="testingElement"/>
<h:outputText value="testingElement"/>
<h:outputText value="testingElement"/>
<h:outputText value="testingElement"/>
<h:outputText value="testingElement"/>
<h:outputText value="testingElement"/>
<h:outputText value="testingElement"/>
<h:outputText value="testingElement"/>
<h:outputText value="testingElement"/>
............. (300 times, of course this is just for testing purposes)
I added these element 300 times in both index1.xhtml and index2.xhtml and repeated the same tests
The results using index1.xhtml (JSF 1.2), I got average time of 19ms
The results using index2.xhtml (JSF 2.2), I got average time of 150ms (!!!!!)
Which is 8 times slower than JSF 1.2
Could someone explain please why JSF 2 is slower than JSF 1? and how can I improve the performance?
UPDATE
Testing out JSF 2 example with elements on a tomcat server, I got average 20ms. I guess the problem is caused from the Wildfly side.
Unfortuanlty I can't change servers. I should find a solution for JSF 2 to work on wildfly.
I tried to upgrade to wildfly 8.2.0 --> Still the same performance issue.
The closest problem I could find after googling is this POST
So I upgraded my JDK to jdk1.7.0_71 --> Still the same performance issue.
UPDATE 2
Here is a log for an ajax request (for one click) sent to Wildfly server. (LOG)
Why is JSF building the whole view although I am only re-rendering a specific ID?
** Note: I don't know if this is how JSF suppose to work or I am just misusing it. **
Thanks in Advance, Tefa