1 2 Previous Next 21 Replies Latest reply on Nov 5, 2007 8:28 AM by Pete Muir

    JSF performance tips in Seam applications


      Improving JSF performance in Seam Applications

      JSF performs best with server side state saving

      So in your web.xml you should have


      Improving render phase performance
      You should increase response buffer (to reduce reallocations at render time)
      (Experimentally I've seen 2 times better render times on larger pages esp with data tables)

      With Sun RI

      If you using facelets add also

      With Seam chances are you are using Ajax4Jsf. Ajax4Jsf adds additional filter which parses XHTML output
      before sending to to browser.

      Use this filter definition
       <display-name>Ajax4jsf Filter</display-name>

      NOTE (IN newer Seam versions same settings are done via components.xml file; check docs)

      Or (better) turn off Ajax4Jsf filter completely if your XHTML is valid.

      There are 2 independent settings
      1) forceparser=false (prevents Ajax4Jsf parser from executing on non Ajax requests)
      2) filter-class=org.ajax4jsf.FastFilter (uses nekko parser which is faster than org.ajax4jsf.Filter)

      In production environment use (see https://facelets.dev.java.net/nonav/docs/dev/docbook.html#config-webapp-init)


      In production JBoss server turn off Seam DEBUG level logging which is turned on by default in JBoss log4j configuration
      It is quite excessive and goes into JBoss server log (you do not see it on console)

      Use Native I/O on your application server. You usually need to install additional DLLs or shared libraries for that,
      check app server documentation and warnings on start-up.

      Check your JVM setting make sure memory settings are adequate for your application.
      JRockIt JVM should perform better than Sun's one.

      Make sure that your jar files contain XSD schemas and DTDs you refer in you XML configuration files
      especially Seam XSD (to prevent fetching them from Internet)

      Javassist performance optimization settings for Seam [TODO:]

      Performance of third party JSF component libraries

      1. Tomahawk (check their recommendation about StreamingAddResource, t:documentBody, t:documentHead, t:document)
      2. RichFaces (see ajax4sf filter tips)
      3. IceFaces [TODO]
      4. Trinidad [TODO]
      5. QuipuKit [TODO]
      6. Woodstock [TODO]

      General UI Design TIPS
      1. Avoid displaying large tables to user. Use pagination
      2. With many components on the page <ui:remove> will help you to identify which one is performance killer
      3. Try different methods to render same content (Ex: rendering tables with ui:repeat vs h:dataTable)
      4. Avoid components which use have JavaScript on client side unless you tested them carefully for
      their client side performance. Very often those render slow in browser cause of JavaScript in them, and
      not because of JSF server side RENDER phase. Fancy ones are usually very slow especially in IE.
      5. When using ajax4jsf you can sometimes reduce APPLY REQUEST VALUES JSF phase (which might be
      significant when large form with many inputs is submitted). Check documentation on ajaxOnly and relevant attributes
      6. Consider immediate=true attributes on elements where you do not need validation
      7. Choose wisely between client side and server side in components such as tabs, collapsible panels, etc
      8. Profile javascript with FireBug
      9. Choose appropriate java collection based on access method (direct, sequential, by key)
      10. Use java StringBuilder vs StringBuffer and + operator
      11. Consider using Web Remoting in some cases vs ajax4jsf for simple things (ex: dependable dropdowns)
      12. Do not over complicate EL expressions, code them in Java in backing bean
      13. Avoid constructing and destroying objects in a loop. Create once and re-use.
      14. Review your code you might be calling same functions repeatedly which could have been called only once

      Hibernate, EJB and back-end performance tips
      [Not covered in details but to mention a few]
      1. Use indexes on database tables appropriately
      2. Reduce number of round trips to database to fetch data (Ex: RowFetchSize in JDBC, join queries,
      insert batch and retrieve generated keys via result sets in one round trip, etc)
      3. USE CACHING (caching is easy to set up with hibernate)
      4. Do not use many transactions while serving one HTML page
      5. Be careful with excessive logging
      6. Understand Seam concept of conversations

      See below details about tips for server and client state savings scenarios

      For server side state with Sun RI see:



      For server side state with MyFaces see:


       Only applicable if state saving method is "server" (= default).
       Defines the amount (default = 20) of the latest views are stored in session.
      If you are not using server state saving
      you still can gain some better results by using JBoss serialization

      for MyFaces follow steps for Client http://wiki.apache.org/myfaces/Performance:


      for Sun RI set (see http://jira.jboss.com/jira/browse/JBAS-3529)


      Code can be found here

      Please, comment if you have more suggestion to add. This is for Seam Wiki.


        1 2 Previous Next