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.

    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 CollabNet, a global leader in enterprise software development, release automation and DevOps solutions, will be a Bronze Sponsor of SYS-CON's 20th International Cloud Expo®, taking place from June 6-8, 2017, at the Javits Center in New York City, NY. CollabNet offers a broad range of solutions with the mission of helping modern organizations deliver quality software at speed. The company’s latest innovation, the DevOps Lifecycle Manager (DLM), supports Value S...
    SYS-CON Events announced today that Outscale will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Outscale's technology makes an automated and adaptable Cloud available to businesses, supporting them in the most complex IT projects while controlling their operational aspects. You boost your IT infrastructure's reactivity, with request responses that only take a few seconds.
    SYS-CON Events announced today that Peak 10, Inc., a national IT infrastructure and cloud services provider, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Peak 10 provides reliable, tailored data center and network services, cloud and managed services. Its solutions are designed to scale and adapt to customers’ changing business needs, enabling them to lower costs, improve performance and focus intern...
    The 21st International Cloud Expo has announced that its Call for Papers is open. Cloud Expo, to be held October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, Big Data, Internet of Things, DevOps, Digital Transformation, Machine Learning and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding busin...
    Internet of @ThingsExpo, taking place October 31 - November 2, 2017, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with the 21st International Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. @ThingsExpo Silicon Valley Call for Papers is now open.
    As cloud adoption continues to transform business, today's global enterprises are challenged with managing a growing amount of information living outside of the data center. The rapid adoption of IoT and increasingly mobile workforce are exacerbating the problem. Ensuring secure data sharing and efficient backup poses capacity and bandwidth considerations as well as policy and regulatory compliance issues.
    DevOps is often described as a combination of technology and culture. Without both, DevOps isn't complete. However, applying the culture to outdated technology is a recipe for disaster; as response times grow and connections between teams are delayed by technology, the culture will die. A Nutanix Enterprise Cloud has many benefits that provide the needed base for a true DevOps paradigm.
    SYS-CON Events announced today that SoftLayer, an IBM Company, has been named “Gold Sponsor” of SYS-CON's 18th Cloud Expo, which will take place on June 7-9, 2016, at the Javits Center in New York, New York. SoftLayer, an IBM Company, provides cloud infrastructure as a service from a growing number of data centers and network points of presence around the world. SoftLayer’s customers range from Web startups to global enterprises.
    Five years ago development was seen as a dead-end career, now it’s anything but – with an explosion in mobile and IoT initiatives increasing the demand for skilled engineers. But apart from having a ready supply of great coders, what constitutes true ‘DevOps Royalty’? It’ll be the ability to craft resilient architectures, supportability, security everywhere across the software lifecycle. In his keynote at @DevOpsSummit at 20th Cloud Expo, Jeffrey Scheaffer, GM and SVP, Continuous Delivery Busine...
    SYS-CON Events announced today that Loom Systems will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Founded in 2015, Loom Systems delivers an advanced AI solution to predict and prevent problems in the digital business. Loom stands alone in the industry as an AI analysis platform requiring no prior math knowledge from operators, leveraging the existing staff to succeed in the digital era. With offices in S...
    SYS-CON Events announced today that DivvyCloud will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. DivvyCloud software enables organizations to achieve their cloud computing goals by simplifying and automating security, compliance and cost optimization of public and private cloud infrastructure. Using DivvyCloud, customers can leverage programmatic Bots to identify and remediate common cloud problems in rea...
    SYS-CON Events announced today that Tintri, Inc, a leading provider of enterprise cloud infrastructure, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Tintri offers an enterprise cloud platform built with public cloud-like web services and RESTful APIs. Organizations use Tintri all-flash storage with scale-out and automation as a foundation for their own clouds – to build agile development environments...
    SYS-CON Events announced today that Progress, a global leader in application development, has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Enterprises today are rapidly adopting the cloud, while continuing to retain business-critical/sensitive data inside the firewall. This is creating two separate data silos – one inside the firewall and the other outside the firewall. Cloud ISVs ofte...
    SYS-CON Events announced today that Tappest will exhibit MooseFS at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. MooseFS is a breakthrough concept in the storage industry. It allows you to secure stored data with either duplication or erasure coding using any server. The newest – 4.0 version of the software enables users to maintain the redundancy level with even 50% less hard drive space required. The software func...
    SYS-CON Events announced today that EARP will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. "We are a software house, so we perfectly understand challenges that other software houses face in their projects. We can augment a team, that will work with the same standards and processes as our partners' internal teams. Our teams will deliver the same quality within the required time and budget just as our partn...
    SYS-CON Events announced today that Interoute has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Interoute is the owner operator of Europe's largest network and a global cloud services platform, which encompasses over 70,000 km of lit fiber, 15 data centers, 17 virtual data centers and 33 colocation centers, with connections to 195 additional partner data centers. Our full-service Unifie...
    SYS-CON Events announced today that Super Micro Computer, Inc., a global leader in compute, storage and networking technologies, will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Supermicro (NASDAQ: SMCI), the leading innovator in high-performance, high-efficiency server technology, is a premier provider of advanced server Building Block Solutions® for Data Center, Cloud Computing, Enterprise IT, Hadoop/...
    SYS-CON Events announced today that Carbonite will exhibit at SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Carbonite protects your entire IT footprint with the right level of protection for each workload, ensuring lower costs and dependable solutions with DoubleTake and Evault.
    SYS-CON Events announced today that Technologic Systems Inc., an embedded systems solutions company, will exhibit at SYS-CON's @ThingsExpo, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Technologic Systems is an embedded systems company with headquarters in Fountain Hills, Arizona. They have been in business for 32 years, helping more than 8,000 OEM customers and building over a hundred COTS products that have never been discontinued. Technologic Systems’ pr...
    SYS-CON Events announced today that Cloudistics, an on-premises cloud computing company, has been named “Bronze Sponsor” of SYS-CON's 20th International Cloud Expo®, which will take place on June 6-8, 2017, at the Javits Center in New York City, NY. Cloudistics delivers a complete public cloud experience with composable on-premises infrastructures to medium and large enterprises. Its software-defined technology natively converges network, storage, compute, virtualization, and management into a ...