You are previewing JBoss AS 5 Performance Tuning.
O'Reilly logo
JBoss AS 5 Performance Tuning

Book Description

Build faster, more efficient enterprise Java applications

  • Follow the practical examples to make your applications as efficient as possible

  • Written to version 5.1 and includes advice on upgrading to version 6.0

  • Accurately configure the persistence layer and clustering service

  • Learn how to tune all components and hardware

  • In Detail

    Today's organizations need to deliver faster services to a large set of people and businesses. In order to survive this challenge, enterprises need to optimize the performance of their application server along with its components and hardware. Writing faster applications is no longer just an option for your products; it's an imperative requirement, which you cannot ignore.

    JBoss AS 5 Performance Tuning will teach you how to deliver fast applications on the JBoss Application Server and Apache Tomcat, giving you a decisive competitive advantage over your competitors. You will learn how to optimize the hardware resources, meeting your application requirements with less expenditure.

    The performance of Java Enterprise applications is the sum of a set of components including the Java Virtual Machine configuration, the application server configuration (in our case, JBoss AS), the application code itself and ultimately the operating system. This book will show you how to apply the correct tuning methodology and use the tuning tools that will help you to monitor and address any performance issues.

    By looking more closely at the Java Virtual Machine, you will get a deeper understanding of what the available options are for your applications and how their performance will be affected. You will learn about thread pool tuning, EJB tuning, JMS tuning, Enterprise Java Beans, and the Java Messaging Service.

    The persistence layer and JBoss Clustering service each have a chapter dedicated to them as they are two of the most crucial elements to configure correctly in order to run a fast application.

    You will also learn how to tune your web server, enabling you to configure and develop web applications that get the most out of the embedded Tomcat web server.

    A practical guide to configure and develop lightning fast applications on JBoss AS and its embedded web server, Apache Tomcat

    Table of Contents

    1. JBoss AS 5 Performance Tuning
      1. Copyright
      2. Credits
      3. About the Author
      4. About the Reviewers
        1. Support files, eBooks, discount offers and more
          1. Why Subscribe?
          2. Free Access for Packt account holders
      6. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Errata
          2. Piracy
          3. Questions
      7. 1. Performance Tuning Concepts
        1. Preface
        2. What you will get from this book?
        3. What is performance?
        4. Scalability: the other side of performance
        5. The tuning process
          1. Tuning in the software development cycle
          2. Building the performance test
            1. Establish a baseline
            2. Collect data
              1. How long should data collection last?
            3. Analyze data
            4. Configure and test again
        6. Tuning Java Enterprise applications
          1. Areas of tuning
        7. Summary
      8. 2. Installing the Tools for Tuning
        1. Welcome to scientific tuning
          1. The rationale behind the choice of the tools
        2. Profiling the Java Virtual Machine
          1. Installing the JVM
          2. Installing VisualVM
            1. Connecting to a local server
            2. Connecting to a remote server
          3. Monitoring your server
            1. The Monitor tab
            2. The Threads tab
            3. The Profiler tab
          4. Collecting snapshots
          5. Extending VisualVM
        3. Profiling your applications with Eclipse Test and Performance Tools Platform (TPTP) Project
          1. Installing the TPTP suite
            1. Updating Eclipse
          2. How to profile an application
            1. Going beyond the basics of TPTP
        4. Load testing your application with JMeter
          1. Building a Test Plan
            1. Step 1: Create a Thread Group
            2. Step 2: Create a Sampler
            3. Step 3: Create a Listener
            4. Making your test plan a bit more realistic
          2. How to create a complex Test Plan
          3. Running JMeter as a shell
        5. Operating system tools and commands
          1. Windows users
          2. Unix users
            1. Dealing with low CPU utilization
            2. Dealing with high CPU utilization
            3. Dealing with high resource contention
            4. Dealing with high disk utilization
        6. Summary
      9. 3. Tuning the Java Virtual Machine
        1. The starting point
        2. Choosing the JVM settings
          1. Setting the correct heap size
            1. The correct amount of memory to grant your application
              1. Step # 1: Finding the maximum heap (-Xmx)
              2. Step # 2: Finding the initial heap size (-Xms)
            2. I cannot allocate enough memory for the JVM!
            3. Where do I configure JVM settings in JBoss AS?
          2. Sizing the garbage collector generations
        3. Which is the correct ratio between the young and old generations?
          1. The garbage collector algorithms
          2. Choosing the right garbage collector for your application
            1. The G1 garbage collector
          3. Debugging garbage collection
          4. Making good use of the memory
            1. Avoid creating large Java objects
            2. Handling 'Out of Memory' errors
            3. Finding the memory leak in your code
        4. A practical example
          1. Application description
          2. Setting up a test bed
            1. Benchmark aftermath
              1. Consideration #1
              2. Consideration #2
              3. Action
              4. Further optimization
        5. Summary
      10. 4. Tuning the JBoss AS
        1. From release 4.x to 5.x, and on
          1. Comparing server releases
          2. Creating a custom application server configuration
        2. JBoss AS pools
          1. The System thread pool
            1. Finding out if the System thread pool is a bottleneck
          2. JDBC connection pool
            1. Calculating the optimal min-pool-size and max-pool-size
            2. Using Prepared Statements efficiently
              1. Two things to be aware of:
            3. Detecting connection leaks
            4. Should you reuse connections or acquire new ones from the pool?
        3. Logging for performance
          1. Choosing the best logging strategy
            1. Which is the fastest appender?
            2. Should I use the AsyncAppender to improve my log throughput?
            3. Which layout should I choose for my logs?
            4. Is it enough to increase the log threshold to get rid of log charge?
            5. How does logging hierarchy influence performance?
        4. Summary
      11. 5. Tuning the Middleware Services
        1. Introduction to Enterprise Java Beans
          1. Session Beans
            1. How to configure the optimal size for stateless pool?
            2. How to configure the optimal size of stateful cache?
            3. Comparing SLSBs and SFSBs performance
              1. When things get wilder
              2. Is it possible that Stateful Beans are faster then Stateless Beans?
            4. Session Beans and Transactions
              1. Customizing JBoss EJB container policies
              2. Customizing the single deployment unit
        2. Introduction to the Java Messaging system
          1. Entering the JBoss Messaging system
          2. Tuning JBoss JMS provider
            1. Tuning JBoss Messaging (JBoss AS 5.x)
              1. How do you tune the JBoss Messaging Connection factory?
              2. How do you tune JBoss Messaging destinations?
            2. Tuning HornetQ (JBoss AS 6.x)
              1. How to configure HornetQ journal for optimal performance?
              2. How do you configure HornetQ transport for optimal performance?
            3. Basic JMS tuning
        3. An example use case with HornetQ
        4. Summary
      12. 6. Tuning the Persistence Layer
        1. Designing a good database
          1. Reducing the space needed by your database
          2. Partitioning the database
          3. Using indexes
        2. Tuning JDBC
          1. Using a Connection Pool
          2. Setting the proper fetch size
          3. Use batch updates for bulk insert/updates
          4. Use Prepared Statements instead of Statements
          5. Tuning JDBC networking
        3. Tuning Hibernate and JPA
          1. Optimizing object retrieval
            1. Limiting the amount of data fetched with pages
            2. Fetching parent and child items with a single query
              1. Combining join fetches and paging
            3. Speeding up your Hibernate queries with batches
            4. Using named queries to speed up your queries
          2. Improving the performance of bulk SQL statements
        4. Evaluating using caches to speed up your queries
          1. Hibernate caches
          2. The first-level cache
          3. The second-level cache
            1. Configuring the second-level cache on JBoss AS
          4. The query cache
            1. Entity cache versus query cache
        5. Optimizing data synchronization
        6. A sample use case
        7. Summary
      13. 7. JBoss AS Cluster Tuning
        1. Introduction to JBoss clustering
        2. Configuring JGroups transport
          1. How to optimize the UDP transport configuration
          2. How to optimize the JGroups' Protocol stack
        3. Tuning JBoss Cache
          1. Understanding JBoss Cache configuration
            1. Configuring cacheMode
            2. Configuring cache concurrency
              1. Configuring the isolationLevel
        4. Tuning session replication
          1. Override SFSB's isModified method
          2. Use buddy replication
            1. Advanced buddy replication
            2. Buddy replication and session affinity
          3. Configure replication granularity and replication trigger
            1. How to configure the replication-trigger
            2. How to configure the replication-granularity
          4. Tuning cache storage
            1. Where does cache data get stored?
        5. Summary
      14. 8. Tomcat Web Server Tuning
        1. JBoss Web server basics
          1. Configuring Connectors for optimal performance
            1. How do you calculate the threads for your application?
              1. A concrete example
            2. The long life of Web threads
            3. Is there a maximum amount of connections the Web server can handle?
          2. Using Apache Portable Runtime
          3. Integrating JBoss Web server with Apache Web server
            1. Load testing Apache-JBoss connectivity
          4. mod_cluster to the rescue?
          5. Last tips before rolling JBoss Web server in production
        2. Summary
      15. 9. Tuning Web Applications on JBoss AS
        1. Choosing a framework for your web applications
          1. Comparing framework performance
            1. The performance of tabular data
            2. The performance of rich tree
          2. Increasing the performance of JSF and RichFaces
            1. Configuring JSF state saving efficiently
            2. Using Ajax to speed up your JSF applications
            3. Speeding up CSS and JavaScript file loading
        2. Tuning web services
          1. Performance of web services
            1. Elements influencing the performance of web services
            2. Reducing the size of SOAP messages
            3. Faster JBossWS provider
              1. The wisdom behind these benchmarks
        3. Summary
      16. A. A Tuned Mind