Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why JSF 2.2 takes more time partial rendering an ajax request on Wildfly

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:

enter image description here

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:

enter image description here

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

enter image description here

The results using index2.xhtml (JSF 2.2), I got average time of 150ms (!!!!!)

enter image description here

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

like image 560
TeFa Avatar asked Sep 30 '22 05:09

TeFa


1 Answers

I finally found out why the ajax response with Wildfly is slow for me only.

It turns out that this performance issue has nothing to do with JSF version or mojarra version. It is actually related to Wildfly configuration (Weld to be specific)

"org.jboss.as.weld" was disabled in my wildfly server. By default, when you download wildfly it is enabled. That's why no one was getting any performance issues.

To enable/disable weld in Wildfly just add/remove the following 2 lines from the standalone.xml found in "{JBOSS_HOME}/standalone/configuration" (the extension and the subsystem):

<extensions>
    ..............
    <extension module="org.jboss.as.weld"/>
    ..............
</extensions>
<profile>
     ..............
    <subsystem xmlns="urn:jboss:domain:weld:2.0"/>
</profile>

If you remove weld and try out the example I mentioned in my question, you should have a delay in ajax responses

I don't know why disabling weld causing this issue but this is different question not related to this current question.

Hope this might help someone

like image 179
TeFa Avatar answered Oct 05 '22 06:10

TeFa