Welcome!

Weblogic Authors: Yeshim Deniz, Elizabeth White, Michael Meiner, Michael Bushong, Avi Rosenthal

Related Topics: Weblogic

Weblogic: Article

How to Diagnose a Performance Problem in a J2EE System

How to Diagnose a Performance Problem in a J2EE System

So you've been told to diagnose a performance problem in a WebLogic J2EE application. Because Java systems are so complex, this can be a bit like diagnosing a rare illness.

To pinpoint the problem accurately you need to have a thorough understanding of the symptoms, be prepared to do a fair amount of investigative work, and then you must determine the proper remedy. This article offers a discussion of some of the most common types of J2EE application performance issues and their causes, followed by suggested guidelines for properly diagnosing and eliminating them.

The Symptoms
What are the symptoms of a WebLogic application performance problem? The symptoms you see guide your search through all possible illnesses. Get a notebook and start asking people for data. Try to separate speculation and theory about the root cause of the problem from hard evidence about the system's behavior. Here's a list of common symptom sets:

  • Consistent slowness: The application is simply always too slow. Changing environmental factors (load, number of database connections) doesn't change the overall response time much.
  • Slower and slower over time: The system gets slower and slower the longer it runs (under a fairly consistent load). Perhaps a threshold is (eventually) reached and the system locks up or melts down with a deluge of errors.
  • Slower and slower under load: The application keeps getting slower and slower with each additional user. If users are kept off the system, it "cools down" and returns to normal.
  • Sporadic hangs or aberrant errors: Occasionally (perhaps based on load or some other condition), users see hangs where pages simply never complete or error pages with an exception and a stack trace. The number of hangs may vary a bit, but never seems to go away completely, even after a "burn in" period.
  • Foreseeable lock ups: Hangs or errors happen a bit at first, but accelerate over time until the system locks up entirely. Typically these are accommodated with "management by restarts."
  • Sudden chaos: The system runs fine, with more or less acceptable and consistent performance for some period of time (could be an hour, could be three days), when "suddenly, for no reason at all," it starts spewing errors, or else locks up.

    Why Is Problem Diagnosis So Complicated?
    There is no set formula that you can apply to derive the performance for a particular usage pattern of a WebLogic application (in hard realtime engineering, techniques like rate monotonic analysis can do exactly this, but let's ignore that for the purposes of this article). The resulting performance is sensitive to whether or not another system somewhere else on the network is hitting a shared back-end service hard. Perhaps it's also dependent on matching the exact versions of the JDBC driver and the database. Maybe a developer wrote some code three years ago that happened to swallow a particular type of exception and the feedback you desperately need to solve the problem is contained in that exception.

    In essence, the performance of a typical business system is an emergent property resulting from thousands of interacting variables and decisions. Like a human body, there are too many interlocking parts and processes to comprehend the totality of the domain. So we simplify, and look for overarching patterns.

    The Diseases
    What are the possible root causes for the symptoms you're seeing? Is it your basic flu or the beginnings of pneumonia? Is the underlying problem internal to the application or is it external to its JVM? See Table 1 for some of the most common causes of poor application performance.

     

    Measuring Vital Statistics
    As the person charged with diagnosing the problem, you should be able to keep track of vital statistics about the health of your WebLogic application. What can you measure? What tools are available to help?

  • Total memory in use: At various levels (JVM heap, OS), Java heap profilers provide visibility into the exact usage of the heap; tools like top, vmstat, and Windows Perfmon give visibility into memory usage at the OS level. For a simple aggregate view of the Java heap try turning on -verbose:gc if available in your JVM.
  • CPU time: In aggregate (available via top and so forth), per component or per method. Some of these metrics can be obtained through the WebLogic Admin Console. They are also available via a Java profiler.
  • Wall-clock time (a.k.a."real" time): Per transaction, per component, per method; viewable as statistical averages or individual data points. Java profilers can yield some of this data, though an application monitoring solution is probably your best bet.
  • Internal resources: Number allocated, number in use, number of waiting clients, average wait time to obtain a resource, average time spent using the resource, average time it takes the resource to accomplish requested work. Application servers typically give some minimal visibility into these numbers.
  • External resources: Number allocated, number in use, number of waiting clients, average wait time, plus measurements directly on the external system such as its view of how quickly it's completing requested work. Don't forget that the operating system and hardware that the application server run on are "external resources" as well - e.g., are you using too many processes or ports? Measuring these resources comes in two forms - measuring the bridge layer to that resource from inside the JVM and measuring the external resource with a tool native to that resource.
  • Network utilization: Bandwidth usage, latency. Network sniffers and equipment give insight into this, though OS-local tools like netstat can help too.
  • System state: Use thread dumps, logs and trace files, stack traces, etc. Or at a deeper level, use values of variables as seen under a debugger.

    Lab Work
    Sometimes the data obtained during one benchmark run will not reveal the answer. And chances are that you will have a limited budget for running experiments and doing lab work to complete your diagnosis. What kinds of experiments can you run? What variables can you change or watch?

  • Try watching the system's behavior over time. Apply a constant load and watch how your measurements vary as time passes. You might see some trends in as little as an hour, or they might take a couple of days. For instance, you might see memory usage increasing over time. As the amount of memory in use reaches its upper limits, the time the JVM spends garbage collecting and the time the OS spends thrashing the memory pages around starts to weigh down the aggregate response time of your users' transactions. Full garbage collections might be so long as to cause timeouts and exceptions on any inflight transactions when the GC was kicked off. Start looking for a resource or memory leak.

  • Try varying the load on the system. Pick three or four workloads (say, 10, 50, and 100 users) and collect data at each of them. Plot your measurements against these loads. You may find, for example, that while your account login servlet responds in less than 50 milliseconds no matter what, the sales tax calculation EJB gets slower and slower linearly with an increasing number of users. If the difference in that EJB's performance under load explains the bulk of the aggregate response time's performance under load, then it's time to dig deeper into that component. Be sure to also try backing off the load and seeing if the system recovers or not.

  • Try compartmentalizing the system and stressing the individual parts in turn. Pick one or more axes of compartmentalization. The primary one is tiers of the system: load balancer, Web server, WebLogic Server, and back end. Other examples include user accounts, internal components, transaction types, and individual pages. Let's say you pick user accounts. Run some load under user A's account and then some load under user B's account (which is hopefully quite different); compare various measurements between the two runs. Or, take the backend systems you use in turn and stress parts of the application that use each back end heavily. Which axis of compartmentalization you pick will depend entirely on which theory you're trying to prove or disprove. Here are some ideas:
    - If a particular user's logon seems to trigger a problem, it might be that user's account profile (e.g., loading the full purchase history of 2,000 orders), or it might be the way he uses the system (e.g., order of page accesses or exact query string he uses to search for a particular document).
    - If you've got a clustered system, try compartmentalizing by individual machines. Despite best efforts, sometimes boxes don't have the latest app server or OS patches, which can contribute to different performance characteristics. Also, pay attention to the load balancer or nanny process to see if it's distributing work fairly and keeping up with inbound requests.

    Diagnosis: Testing Your Theories
    At this point, you should have enough information to form theories about the cause of the performance bottleneck (see Table 1). To confirm that your theory is correct or to differentiate between multiple competing theories, you'll need to analyze more information or run additional benchmarks on the system. Here are a few guidelines to help you out.

  • To distinguish between poor coding (either an application component or layeritis) and a bottleneck (internal or external), try looking at aggregate CPU usage. If it doesn't vary under load but overall response time does, then the application is spending most of its time waiting.
  • Just because it appears to be a problem with an external resource doesn't mean you can immediately blame it on that resource. Layeritis or a networking problem, for example, can cause the database to appear slow even though it's not. Or, more simply, your demands on that database could be unreasonable (2 million row joins across three tables, each time a user logs in). Always compare response times at the bridge layer (e.g., JDBC driver) with those provided by the resource or a tool native to it (e.g., DBA Studio).
  • Architectural diagrams help you understand overall interactions inside the system, but don't forget that the map is not the territory. Coding mistakes or misunderstandings of architectural intent may make the actual behavior of the system vary from what's expected. Trust hard numbers from a performance tool more than a document claiming that only one SQL statement will be issued per user transaction.
  • Apply Occam's razor. Let's say your two competing theories are that either there's a poorly coded component in the 2 million lines of code system that wasn't integrated until last week, or that the JVM's Just-In- Time compiler is creating bad machine code which is destroying the memory integrity of this variable. Unless you have specific data to prove otherwise (and I have seen the second happen), investigate the first theory more fully than the second one. J2EE systems are prone to byzantine failures, but don't let that dissuade you from testing a simpler theory first.
  • Absence of errors in the log file does not imply absence of errors. Exceptions don't get written to logs for many reasons; perhaps a programmer thought that something would "never happen" and swallowed the exception, or perhaps some component has a fallback mechanism it can use and therefore doesn't log the first failure.

    Example Diagnosis
    Let's step through an example. Your WebLogic application exhibits the symptom of increasing slowness under load. The more users you pile on, the slower things get. Once the load is removed, the system cools down with no side effects. You measure this primary symptom and find the following (time measurement is for end-toend completion of a single typical transaction) and get the results shown in Table 2.

     

    You form a few theories. Perhaps the disease here is a badly coded component or perhaps it's a bottleneck on a back-end system. It could be a synchronization chokepoint. How can you tell the difference? Suppose you also measured aggregate CPU usage of the application server during the load runs and got the results shown in Table 3.

     

    It looks like the system isn't CPU bound, which means that it's spending most of its time waiting. But is it internal (a synchronization traffic jam, for instance) or external (slow database)? Well, let's suppose we gather a few more numbers and come up with Table 4.

     

    It doesn't appear to be an internal bottleneck waiting for database connections - instead, it appears to be the JDBC query itself. Not only does the JDBC query vary with the overall transaction time, but its poor performance explains the bulk of the overall poor performance. We're still not quite done, though. You still have three major theories to sort through: Is it the database itself that's slow, is the application making unreasonable demands on the database, or does the problem lie in some layer between the application and the database? You pull up the database's vendor-specific tool to see response times from its point of view. You'd hope to see numbers such as those in Table 5.

     

    If you didn't see this information, then you might dive back into the JDBC driver and hope to find some sort of synchronization problem inside it (remember, the CPU isn't overwhelmed). Fortunately, in this case you've narrowed the specific problem down to a database query. Figuring out if the query's demands are reasonable enough requires some domain knowledge and familiarity with the system, but perhaps in this case it simply turns out that the query compares an unindexed field against a foreign key. You work with the DBA, who changes the indexing scheme to make this query faster, and you've found your cure.

    Conclusion
    Diagnosing a performance bottleneck in a WebLogic J2EE application can be a difficult journey. Keep your wits about you, separate fact from speculation, and always confirm your hypotheses with hard evidence. Hopefully I've given you a taxonomy of useful ideas to think about and experiment with. Like debugging, this is still a black art but careful thinking will see you through. Good luck!

  • More Stories By John Bley

    John Bley is a software engineer for Wily Technology. He has extensive experience with Java programming and architecture. For this article, he has drawn on the experiences of Wily's enterprise customers, who are responsible for managing complex J2EE environments.

    Comments (2) View Comments

    Share your thoughts on this story.

    Add your comment
    You must be signed in to add a comment. Sign-in | Register

    In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


    Most Recent Comments
    Paddy Ganti 01/02/04 09:57:27 AM EST

    I like the way analysis has been done in your article.Please keep it up by posting further case studies like this.

    [email protected] 11/11/03 08:03:34 PM EST
    @ThingsExpo Stories
    SYS-CON Events announced today that MobiDev, a client-oriented software development company, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place October 31-November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. MobiDev is a software company that develops and delivers turn-key mobile apps, websites, web services, and complex software systems for startups and enterprises. Since 2009 it has grown from a small group of passionate engineers and business...
    Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 21st Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devic...
    SYS-CON Events announced today that Dasher Technologies will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Dasher Technologies, Inc. ® is a premier IT solution provider that delivers expert technical resources along with trusted account executives to architect and deliver complete IT solutions and services to help our clients execute their goals, plans and objectives. Since 1999, we'v...
    SYS-CON Events announced today that Ayehu will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct. 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Ayehu provides IT Process Automation & Orchestration solutions for IT and Security professionals to identify and resolve critical incidents and enable rapid containment, eradication, and recovery from cyber security breaches. Ayehu provides customers greater control over IT infrastructure thro...
    SYS-CON Events announced today that Elastifile will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 - Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Elastifile Cloud File System (ECFS) is software-defined data infrastructure designed for seamless and efficient management of dynamic workloads across heterogeneous environments. Elastifile provides the architecture needed to optimize your hybrid cloud environment, by facilitating efficient...
    SYS-CON Events announced today that Grape Up will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct. 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company specializing in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market across the U.S. and Europe, Grape Up works with a variety of customers from emergi...
    SYS-CON Events announced today that Grape Up will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct. 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Grape Up is a software company specializing in cloud native application development and professional services related to Cloud Foundry PaaS. With five expert teams that operate in various sectors of the market across the U.S. and Europe, Grape Up works with a variety of customers from emergi...
    SYS-CON Events announced today that Golden Gate University will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Since 1901, non-profit Golden Gate University (GGU) has been helping adults achieve their professional goals by providing high quality, practice-based undergraduate and graduate educational programs in law, taxation, business and related professions. Many of its courses are taug...
    When shopping for a new data processing platform for IoT solutions, many development teams want to be able to test-drive options before making a choice. Yet when evaluating an IoT solution, it’s simply not feasible to do so at scale with physical devices. Building a sensor simulator is the next best choice; however, generating a realistic simulation at very high TPS with ease of configurability is a formidable challenge. When dealing with multiple application or transport protocols, you would be...
    21st International Cloud Expo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Me...
    Recently, WebRTC has a lot of eyes from market. The use cases of WebRTC are expanding - video chat, online education, online health care etc. Not only for human-to-human communication, but also IoT use cases such as machine to human use cases can be seen recently. One of the typical use-case is remote camera monitoring. With WebRTC, people can have interoperability and flexibility for deploying monitoring service. However, the benefit of WebRTC for IoT is not only its convenience and interopera...
    WebRTC is great technology to build your own communication tools. It will be even more exciting experience it with advanced devices, such as a 360 Camera, 360 microphone, and a depth sensor camera. In his session at @ThingsExpo, Masashi Ganeko, a manager at INFOCOM Corporation, will introduce two experimental projects from his team and what they learned from them. "Shotoku Tamago" uses the robot audition software HARK to track speakers in 360 video of a remote party. "Virtual Teleport" uses a...
    When shopping for a new data processing platform for IoT solutions, many development teams want to be able to test-drive options before making a choice. Yet when evaluating an IoT solution, it’s simply not feasible to do so at scale with physical devices. Building a sensor simulator is the next best choice; however, generating a realistic simulation at very high TPS with ease of configurability is a formidable challenge. When dealing with multiple application or transport protocols, you would be...
    SYS-CON Events announced today that Secure Channels, a cybersecurity firm, will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. Secure Channels, Inc. offers several products and solutions to its many clients, helping them protect critical data from being compromised and access to computer networks from the unauthorized. The company develops comprehensive data encryption security strategie...
    SYS-CON Events announced today that App2Cloud will exhibit at SYS-CON's 21st International Cloud Expo®, which will take place on Oct. 31 – Nov 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA. App2Cloud is an online Platform, specializing in migrating legacy applications to any Cloud Providers (AWS, Azure, Google Cloud).
    WebRTC is the future of browser-to-browser communications, and continues to make inroads into the traditional, difficult, plug-in web communications world. The 6th WebRTC Summit continues our tradition of delivering the latest and greatest presentations within the world of WebRTC. Topics include voice calling, video chat, P2P file sharing, and use cases that have already leveraged the power and convenience of WebRTC.
    Internet-of-Things discussions can end up either going down the consumer gadget rabbit hole or focused on the sort of data logging that industrial manufacturers have been doing forever. However, in fact, companies today are already using IoT data both to optimize their operational technology and to improve the experience of customer interactions in novel ways. In his session at @ThingsExpo, Gordon Haff, Red Hat Technology Evangelist, shared examples from a wide range of industries – including en...
    Detecting internal user threats in the Big Data eco-system is challenging and cumbersome. Many organizations monitor internal usage of the Big Data eco-system using a set of alerts. This is not a scalable process given the increase in the number of alerts with the accelerating growth in data volume and user base. Organizations are increasingly leveraging machine learning to monitor only those data elements that are sensitive and critical, autonomously establish monitoring policies, and to detect...
    To get the most out of their data, successful companies are not focusing on queries and data lakes, they are actively integrating analytics into their operations with a data-first application development approach. Real-time adjustments to improve revenues, reduce costs, or mitigate risk rely on applications that minimize latency on a variety of data sources. Jack Norris reviews best practices to show how companies develop, deploy, and dynamically update these applications and how this data-first...
    Intelligent Automation is now one of the key business imperatives for CIOs and CISOs impacting all areas of business today. In his session at 21st Cloud Expo, Brian Boeggeman, VP Alliances & Partnerships at Ayehu, will talk about how business value is created and delivered through intelligent automation to today’s enterprises. The open ecosystem platform approach toward Intelligent Automation that Ayehu delivers to the market is core to enabling the creation of the self-driving enterprise.