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.

    flaviols@intercorp.com.br 11/11/03 08:03:34 PM EST
    @ThingsExpo Stories
    Join IBM November 1 at 21st Cloud Expo at the Santa Clara Convention Center in Santa Clara, CA, and learn how IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Cognitive analysis impacts today’s systems with unparalleled ability that were previously available only to manned, back-end operations. Thanks to cloud processing, IBM Watson can bring cognitive services and AI to intelligent, unmanned systems. Imagine a robot vacuum that becomes your personal assistant tha...
    Widespread fragmentation is stalling the growth of the IIoT and making it difficult for partners to work together. The number of software platforms, apps, hardware and connectivity standards is creating paralysis among businesses that are afraid of being locked into a solution. EdgeX Foundry is unifying the community around a common IoT edge framework and an ecosystem of interoperable components.
    As popularity of the smart home is growing and continues to go mainstream, technological factors play a greater role. The IoT protocol houses the interoperability battery consumption, security, and configuration of a smart home device, and it can be difficult for companies to choose the right kind for their product. For both DIY and professionally installed smart homes, developers need to consider each of these elements for their product to be successful in the market and current smart homes.
    Infoblox delivers Actionable Network Intelligence to enterprise, government, and service provider customers around the world. They are the industry leader in DNS, DHCP, and IP address management, the category known as DDI. We empower thousands of organizations to control and secure their networks from the core-enabling them to increase efficiency and visibility, improve customer service, and meet compliance requirements.
    With major technology companies and startups seriously embracing Cloud strategies, now is the perfect time to attend 21st Cloud Expo October 31 - November 2, 2017, at the Santa Clara Convention Center, CA, and June 12-14, 2018, at the Javits Center in New York City, NY, and learn what is going on, contribute to the discussions, and ensure that your enterprise is on the right path to Digital Transformation.
    SYS-CON Events announced today that mruby Forum will exhibit at the Japan External Trade Organization (JETRO) Pavilion 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. mruby is the lightweight implementation of the Ruby language. We introduce mruby and the mruby IoT framework that enhances development productivity. For more information, visit http://forum.mruby.org/.
    Digital transformation is changing the face of business. The IDC predicts that enterprises will commit to a massive new scale of digital transformation, to stake out leadership positions in the "digital transformation economy." Accordingly, attendees at the upcoming Cloud Expo | @ThingsExpo at the Santa Clara Convention Center in Santa Clara, CA, Oct 31-Nov 2, will find fresh new content in a new track called Enterprise Cloud & Digital Transformation.
    Most technology leaders, contemporary and from the hardware era, are reshaping their businesses to do software. They hope to capture value from emerging technologies such as IoT, SDN, and AI. Ultimately, irrespective of the vertical, it is about deriving value from independent software applications participating in an ecosystem as one comprehensive solution. In his session at @ThingsExpo, Kausik Sridhar, founder and CTO of Pulzze Systems, will discuss how given the magnitude of today's applicati...
    Smart cities have the potential to change our lives at so many levels for citizens: less pollution, reduced parking obstacles, better health, education and more energy savings. Real-time data streaming and the Internet of Things (IoT) possess the power to turn this vision into a reality. However, most organizations today are building their data infrastructure to focus solely on addressing immediate business needs vs. a platform capable of quickly adapting emerging technologies to address future ...
    SYS-CON Events announced today that NetApp has been named “Bronze Sponsor” of 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. NetApp is the data authority for hybrid cloud. NetApp provides a full range of hybrid cloud data services that simplify management of applications and data across cloud and on-premises environments to accelerate digital transformation. Together with their partners, NetApp emp...
    In a recent survey, Sumo Logic surveyed 1,500 customers who employ cloud services such as Amazon Web Services (AWS), Microsoft Azure, and Google Cloud Platform (GCP). According to the survey, a quarter of the respondents have already deployed Docker containers and nearly as many (23 percent) are employing the AWS Lambda serverless computing framework. It’s clear: serverless is here to stay. The adoption does come with some needed changes, within both application development and operations. Tha...
    SYS-CON Events announced today that Avere Systems, a leading provider of enterprise storage for the hybrid cloud, 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. Avere delivers a more modern architectural approach to storage that doesn't require the overprovisioning of storage capacity to achieve performance, overspending on expensive storage media for inactive data or the overbui...
    SYS-CON Events announced today that Avere Systems, a leading provider of hybrid cloud enablement solutions, 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. Avere Systems was created by file systems experts determined to reinvent storage by changing the way enterprises thought about and bought storage resources. With decades of experience behind the company’s founders, Avere got its ...
    Amazon is pursuing new markets and disrupting industries at an incredible pace. Almost every industry seems to be in its crosshairs. Companies and industries that once thought they were safe are now worried about being “Amazoned.”. The new watch word should be “Be afraid. Be very afraid.” In his session 21st Cloud Expo, Chris Kocher, a co-founder of Grey Heron, will address questions such as: What new areas is Amazon disrupting? How are they doing this? Where are they likely to go? What are th...
    As hybrid cloud becomes the de-facto standard mode of operation for most enterprises, new challenges arise on how to efficiently and economically share data across environments. In his session at 21st Cloud Expo, Dr. Allon Cohen, VP of Product at Elastifile, will explore new techniques and best practices that help enterprise IT benefit from the advantages of hybrid cloud environments by enabling data availability for both legacy enterprise and cloud-native mission critical applications. By rev...
    Recently, REAN Cloud built a digital concierge for a North Carolina hospital that had observed that most patient call button questions were repetitive. In addition, the paper-based process used to measure patient health metrics was laborious, not in real-time and sometimes error-prone. In their session at 21st Cloud Expo, Sean Finnerty, Executive Director, Practice Lead, Health Care & Life Science at REAN Cloud, and Dr. S.P.T. Krishnan, Principal Architect at REAN Cloud, will discuss how they b...
    SYS-CON Events announced today that SkyScale 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. SkyScale is a world-class provider of cloud-based, ultra-fast multi-GPU hardware platforms for lease to customers desiring the fastest performance available as a service anywhere in the world. SkyScale builds, configures, and manages dedicated systems strategically located in maximum-security...
    High-velocity engineering teams are applying not only continuous delivery processes, but also lessons in experimentation from established leaders like Amazon, Netflix, and Facebook. These companies have made experimentation a foundation for their release processes, allowing them to try out major feature releases and redesigns within smaller groups before making them broadly available. In his session at 21st Cloud Expo, Brian Lucas, Senior Staff Engineer at Optimizely, will discuss how by using...
    In this strange new world where more and more power is drawn from business technology, companies are effectively straddling two paths on the road to innovation and transformation into digital enterprises. The first path is the heritage trail – with “legacy” technology forming the background. Here, extant technologies are transformed by core IT teams to provide more API-driven approaches. Legacy systems can restrict companies that are transitioning into digital enterprises. To truly become a lead...
    SYS-CON Events announced today that Daiya Industry will exhibit at the Japanese Pavilion 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. Ruby Development Inc. builds new services in short period of time and provides a continuous support of those services based on Ruby on Rails. For more information, please visit https://github.com/RubyDevInc.