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

Related Topics: Weblogic

Weblogic: Article

Effective EJB: Make EJBs Work For You

"Java Development is at a Crossroads."

Do Not Use Long Primary Keys
Designing entity beans with long primary keys results in performance degradation when the data in the underlying data store increases. Primary keys are used by the database for lookup. Database indexes make heavy use of primary keys to build hashes. Long primary keys will require more computations to hash and compare than shorter keys. Databases cache index fields to optimize performance on relational joins. Long primary keys tend to eat lot of space in the cache area, thereby opening the gates for a potentially thrashing situation.

However, how long is long? There is no bench mark for how long a primary key can be. This length depends on the volume of data anticipated in the target database table.

Some Guidelines for Effective EJB Performance Tuning
Your system needs some tuning irrespective of any good design, coding, and engineering practices adopted during development. This is particularly true of EJB-based systems as they are complex enough to warrant high testing. The following are some guidelines for performance tuning.

  • What is performance? Performance is the measure of an application's ability to live up to the expectations within the environmental constraints of an enterprise.
  • Performance tuning the software engineering way - know the limitations. Expecting throughput increase by a rate of 10X with only 32MB RAM and DEC PDP 11 machine is impossible.
  • Measure, don't guess! Define what is expected in absolute terms. Simply iterating that performance needs to be improved will not help. Come up with an absolute figure; for example, method mytrans() should complete in three seconds. Most times it is advisable for the end users to come up with some expected performance numbers.
  • Use the container. EJB containers are designed to provide a higher level of scalability through clustering, load balancing, and other means. It is important to learn the capabilities before you start tuning your performance.
  • Good coding is second to none. Use design patterns wherever and whenever applicable to enable a high level of maintainability. This will help by enabling easier tuning of applications.
  • Collect statistics. Before and after each step of tweaking and tuning, collect statistics. These numbers are invaluable to further planning. Compare the numbers, analyze the improvements achieved, and then plan forward if necessary.
  • Take one step at a time - Rome was not built in a day. Don't do everything at step 1. Go step by step and measure at the end of each step. This will help to isolate the performance bottleneck.
  • Know when to stop. Knowing when to stop is the key to tuning. Overtuning will have dire consequences. Well-documented performance criteria will help identify when to stop further turning.
  • Be among good workmen - choose your tool. Use tools to guide you through the tuning process. For example, JUnitPerf will help you find the response times in various scenarios. Profilers are great tools for isolating the problem areas.
  • Do not PLAN, do planning. Do not document a tuning master plan and stick to it. Performance tuning is an iterative and repeatable process. At the end of each step, measure and replan the process and define new horizons. Master plans are not practical for software turning.
Some Loose Ends
Using XML as a Silver Bullet
Filling JMS messages with XML in the name of flexibility and scalability is no panacea. Most designers/developers tend to overuse XML because it's new and hot. Overuse of XML when smart alternatives exist will severely impact application scalability.

XML is a great technology for bringing together heterogeneous environments, but it is best used judiciously. Bear in mind that XML brings in some costs too. Since XML is typeless (everything is a string), there is a type conversion and checking that need to be done. Also, parsing huge XML messages is a resource-consuming process. The overuse of XML is generally seen in JMS implementations. In this case, the MDB spends lot of time type checking and parsing the incoming XML message.

Do Not Think Too Much About Portability
One of the goals of EJB specification is to allow creation of portable components. However in reality, it is necessary to depend on extensions and enhancements that are provided by your container provider. For example, every vendor has his own proprietary deployment descriptor that allows for tuning the behavior of EJB instances. It is important to recognize that portability, though a desired feature, is not necessarily a requirement. Organizations seldom change application servers, and it is likely that you'll deploy your EJB in the same server. Thus it is advisable to take full advantage of additional features provided by your container provider.

Use Entity Beans Sparingly
As already discussed, entity beans do not naturally fit into the coarse-grained nature of distributed services. As such, they are very resource consuming and hard to change and maintain. The original goal of entity bean use is that we be able to deploy a domain model on Machine A and another domain model on Machine B, and they interoperate seamlessly through location transparency. This is seldom true because of the connecting glue called network. This resulted in developers trying to tweak the entity bean model only to make things worse.

As the lightweight container moment gains popularity, we have very good alternatives for providing transparent persistence. Hibernate, for example, comes from the open source world. It provides the transparent persistence services to POJOs. It is easily configurable and does not need a full-blown J2EE container. Sun has a new standard for transparent persistence through JDO. Although JDO is in its infancy and has not been fully embraced by J2EE vendors yet, it provides a lot of promise and is a fairly simple API.

Test, Test, and Test
Distributed components are long-term investments and they play a very vital role in a company's IT infrastructure. They are heavily used and a single failure can cause huge losses. Care must be taken to ensure that the middleware components perform very well in production. This can be ensured by rigorous testing in each phase of the development life cycle. EJB components need specialized testing as they live inside a managed environment (container). From the design to coding to integration and deployment, EJB components should be tested with all real-world use cases to ensure smoother production transition.

EJB 3.0 - The Road Ahead
The EJB architecture is probably the only J2EE component that has failed so miserably in delivering J2EE's promise of increased developer productivity thorough ease of development. EJB 3.0 makes another attempt at delivering that promise by reducing EJB's complexity for developers.

More Stories By Shankar Itchapurapu

Shankar Itchapurapu is a software engineer at Oracle in India. He holds a Master's degree in Computer Applications. You can e-mail Shankar at [email protected]

Comments (3)

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.

IoT & Smart Cities Stories
The deluge of IoT sensor data collected from connected devices and the powerful AI required to make that data actionable are giving rise to a hybrid ecosystem in which cloud, on-prem and edge processes become interweaved. Attendees will learn how emerging composable infrastructure solutions deliver the adaptive architecture needed to manage this new data reality. Machine learning algorithms can better anticipate data storms and automate resources to support surges, including fully scalable GPU-c...
Machine learning has taken residence at our cities' cores and now we can finally have "smart cities." Cities are a collection of buildings made to provide the structure and safety necessary for people to function, create and survive. Buildings are a pool of ever-changing performance data from large automated systems such as heating and cooling to the people that live and work within them. Through machine learning, buildings can optimize performance, reduce costs, and improve occupant comfort by ...
The explosion of new web/cloud/IoT-based applications and the data they generate are transforming our world right before our eyes. In this rush to adopt these new technologies, organizations are often ignoring fundamental questions concerning who owns the data and failing to ask for permission to conduct invasive surveillance of their customers. Organizations that are not transparent about how their systems gather data telemetry without offering shared data ownership risk product rejection, regu...
René Bostic is the Technical VP of the IBM Cloud Unit in North America. Enjoying her career with IBM during the modern millennial technological era, she is an expert in cloud computing, DevOps and emerging cloud technologies such as Blockchain. Her strengths and core competencies include a proven record of accomplishments in consensus building at all levels to assess, plan, and implement enterprise and cloud computing solutions. René is a member of the Society of Women Engineers (SWE) and a m...
Poor data quality and analytics drive down business value. In fact, Gartner estimated that the average financial impact of poor data quality on organizations is $9.7 million per year. But bad data is much more than a cost center. By eroding trust in information, analytics and the business decisions based on these, it is a serious impediment to digital transformation.
Digital Transformation: Preparing Cloud & IoT Security for the Age of Artificial Intelligence. As automation and artificial intelligence (AI) power solution development and delivery, many businesses need to build backend cloud capabilities. Well-poised organizations, marketing smart devices with AI and BlockChain capabilities prepare to refine compliance and regulatory capabilities in 2018. Volumes of health, financial, technical and privacy data, along with tightening compliance requirements by...
Predicting the future has never been more challenging - not because of the lack of data but because of the flood of ungoverned and risk laden information. Microsoft states that 2.5 exabytes of data are created every day. Expectations and reliance on data are being pushed to the limits, as demands around hybrid options continue to grow.
Digital Transformation and Disruption, Amazon Style - What You Can Learn. Chris Kocher is a co-founder of Grey Heron, a management and strategic marketing consulting firm. He has 25+ years in both strategic and hands-on operating experience helping executives and investors build revenues and shareholder value. He has consulted with over 130 companies on innovating with new business models, product strategies and monetization. Chris has held management positions at HP and Symantec in addition to ...
Enterprises have taken advantage of IoT to achieve important revenue and cost advantages. What is less apparent is how incumbent enterprises operating at scale have, following success with IoT, built analytic, operations management and software development capabilities - ranging from autonomous vehicles to manageable robotics installations. They have embraced these capabilities as if they were Silicon Valley startups.
As IoT continues to increase momentum, so does the associated risk. Secure Device Lifecycle Management (DLM) is ranked as one of the most important technology areas of IoT. Driving this trend is the realization that secure support for IoT devices provides companies the ability to deliver high-quality, reliable, secure offerings faster, create new revenue streams, and reduce support costs, all while building a competitive advantage in their markets. In this session, we will use customer use cases...