Welcome!

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

Related Topics: Weblogic

Weblogic: Article

Improving Performance, Avoiding Hung Threads, and Keeping It Simple

Improving Performance, Avoiding Hung Threads, and Keeping It Simple

Q. What are some quick steps I can take to improve CPU utilization?
A.
If your application is experiencing serious performance problems, I recommend that you perform a thorough analysis to determine the root cause. But if you're looking for some quick ways to optimize application performance, here are a few tips that may help.

  • Distribute your JSPs. Much of the CPU burn for many applications is consumed by parsing back-end data up into data structures for handoff to the application's view (JSPs typically). If the CPU is burned in that part of the application, then chances are very good that it also gets burned while pulling apart these data structures when building the JSP itself. Try distributing your JSPs into a container separate from the business logic. As a result, more CPU will be available to help out with back-end data requests. Better yet, you'll understand whether the "front" or the "back" of your architecture burns more resources, so you can tune and/or add resources accordingly.

  • Review the semantics of your application's back-end connection usage (JDBC, JMS, etc.). Make sure all calls to distributed remote systems are wrapped with sensible timeouts (i.e., if a call hasn't come back in 15 or 30 seconds when it normally takes less than 5, then send a sensible error message back to the user). This helps you avoid the risk of hanging the entire application server due to a single failed resource.

  • Reduce the amount of data offered in search results. If your application returns search results, make sure it hands back less data at a time - not just to the user but to the WebLogic Server instance itself. If your application is fast, they won't mind clicking again. Large amounts of data can create a "pig in the python" problem throughout your entire application architecture.
  • Reduce unnecessary logging. As I mentioned in an earlier column (WLDJ, Vol. 2, issue 7), while logging is a great analytical tool, too much logging can cause excess CPU utilization. Consider putting a dynamic switch into your application that will allow you to redirect the logging to /dev/null whenever it is unnecessary. Additionally, when logging, you can use the features available in JDK 1.4 to select the appropriate level of granularity.

  • Measure, measure, measure. This final point is very important. There is no substitute for gaining a complete understanding of where your application is using resources and why. If you understand the answer to those questions, you'll know what it takes to improve your performance.

    Q: What are some good defensive programming techniques I can mandate for my developers to avoid a "hung thread" or "hung server" in production?
    A:
    In another column (WLDJ, Vol. 2, issue 6), I discussed finding the causes of stalled threads. Here are some techniques that can help you avoid them altogether. In most cases, a "hung thread" is one that has blocked on contacting a back-end system for data needed to dispatch its request. The most common of these is a database, in which case it is probably being contacted via JDBC. If your application is passing messages, it may be a JMS implementation. If it is a proprietary or legacy system, it might talk only a specific protocol over TCP/IP. The list goes on.

    The key is to make sure that the application knows what to do if the resource it needs is just not available. Most of the time, this isn't a problem because the code for timing out sockets to the remote DB server is all in the JDBC driver.

    When you have to handle timing out a connection yourself, the situation is significantly more complicated. David Reilly wrote a very informative article on handling network timeouts entitled "Simple Handling of Network Timeouts," which can still be found on the Web.

    There is no replacement for understanding how your transactions will behave at the code level when remote resources become unavailable. There are, however, a number of parameters in the various layers of software supporting your application that may be tuned to obtain better failure patterns right away. WebLogic Server itself includes a number of parameters for tuning how the EJB container transactions are timed out (http://edocs.bea.com/wls/docs70/ejb/ reference.html#1072610).

    The moral of the story is: if you're struggling with hung threads and suspends in your application, or you want to avoid struggling with them, spend time thinking about how each and every one of the connector components in your application will behave when the back-end resource on which they rely disappears.

    Q. Of the application architectures you've seen, which have been the most successful?
    A:
    When it comes to matters like this, my philosophy has always been to keep it simple. In my experience, the projects that usually end up on time and under budget are those that have been completed in the most straightforward way possible.

    Does this mean that you can ignore the principles of object-oriented design? No, but there may be times when you have too much of a good thing. Most architects of object-oriented applications will rightly object to two different teams creating their own versions of a thread pool. Doing this will result in a larger, less maintainable code base; bugs in one version will not necessarily get fixed in the other. But what about the logging strategy adopted for an application? One application may need logging for debugging and performance analysis. Another may need it to audit every transaction, perhaps for security purposes. Insisting on a unified logging framework for an entire enterprise might result in a logging approach that doesn't necessarily make sense for each application. For many applications, having a separate servlet for every important application use case, a small library of business logic that is not necessarily EJBs, and a JSP for each customer view of the Web application just might be exactly what you need. The bottom line is, keep it simple but be sensible; don't break the rules unless you know them first.

  • More Stories By Lewis Cirne

    Lew Cirne is the founder of New Relic, the first provider of on-demand (SaaS) application management tools for cloud or datacenter applications. A seasoned entrepreneur, technologist, and enterprise software pioneer, he has been focused on application performance management for more than ten years. Cirne holds seven patents related to application performance technology. Most recently he was an Entrepreneur in Residence at Benchmark Capital. He founded and was first CEO of Wily Technology and earlier held senior engineering positions at Apple and Hummingbird Communications.

    Comments (0)

    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.


    @ThingsExpo Stories
    SYS-CON Events announced today that Massive Networks, that helps your business operate seamlessly with fast, reliable, and secure internet and network solutions, has been named "Exhibitor" 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. As a premier telecommunications provider, Massive Networks is headquartered out of Louisville, Colorado. With years of experience under their belt, their team of...
    SYS-CON Events announced today that Taica 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. Taica manufacturers Alpha-GEL brand silicone components and materials, which maintain outstanding performance over a wide temperature range -40C to +200C. For more information, visit http://www.taica.co.jp/english/.
    SYS-CON Events announced today that TidalScale, a leading provider of systems and services, 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. TidalScale has been involved in shaping the computing landscape. They've designed, developed and deployed some of the most important and successful systems and services in the history of the computing industry - internet, Ethernet, operating s...
    SYS-CON Events announced today that MIRAI Inc. 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. MIRAI Inc. are IT consultants from the public sector whose mission is to solve social issues by technology and innovation and to create a meaningful future for people.
    SYS-CON Events announced today that IBM has been named “Diamond Sponsor” of SYS-CON's 21st Cloud Expo, which will take place on October 31 through November 2nd 2017 at the Santa Clara Convention Center in Santa Clara, California.
    SYS-CON Events announced today that TidalScale 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. TidalScale is the leading provider of Software-Defined Servers that bring flexibility to modern data centers by right-sizing servers on the fly to fit any data set or workload. TidalScale’s award-winning inverse hypervisor technology combines multiple commodity servers (including their ass...
    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.
    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.
    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.
    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.
    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 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.
    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...