Thursday, 28 October 2010

Creating weblogic domain template using weblogic template builder

Domain templates are used to create(or extend weblogic server domains) with pre-configured resources such as JDBC, security realms, external libraries, log4j components. 


So when you create new domain you do not need to go to server console and create resources such as data source, etc.  While creating domain by using template you will have those resources configured already for you.

Lets say, you have a team and you like everybody to have same configuration, then create a template share with the team. Even it is very much useful if you have new member in the team.


1]. Go to $WL_HOME/common/bin & run config_builder.cmd ( Win ) , config_builder.sh ( Unix/Linux )


2]. Click on "Create a Domain Template"



Select template name & location and click on next

Select "Select a template" , select "Basic Weblogic Server Domain" option and next


Select default and next


Enter username and password for your domain


Add the resources from your existing domain to the new domain you are going to create, next

Select your database, next

 Enter you Admin Server name , listen address and port, next

 Select Next


Select Next

Select Next


 Click on Create Domain


Now, Run the domain creation wizard and during prompt select domain source, select your above created template.



How to view JNDI Tree and class ?

Login to console
Click on server name on left hand side
Select View JNDI tree under Configuration -> General


Expand nodes on left hand side, click on JNDI name and see class on right hand side.


Performance Tuning Part - 3 : Work Managers



1]. WebLogic Server allows you to configure how your application prioitizes the   
     execution of its work. 

2]. Based on rules you define and by monitoring actual runtime performance, WebLogic   
     Server can optimize the performance of your application and maintain service level  
     agreements. 

3].  You define the rules and constraints for your application by defining a Work Manger  
      and applying it either globally to WebLogic Server domain or to a specifi  
      application component.

4]. In WebLogic Server 9.0 there is a single thread pool, in which all types of work are  
     executed. WebLogic Server prioritizes work based on rules you define, and run-
     time metrics, including the actual time it takes to execute a request and the rate at
     which requests are entering and  leaving the pool.

5]. The common thread pool changes its size automatically to maximize
      throughput. The queue monitors throughput over time and based on history,
      determines whether to adjust the thread count. 

     For example, if historical throughput statistics indicate that a higher thread count  
     increased  throughput, WebLogic increases the thread count. Similarly, if statistics
     indicate that fewer threads did not reduce throughput, WebLogic decreases the  
     thread count. This new strategy makes it easier for administrators to allocate
     processing resources and manage performance, 
     avoiding the effort and complexity involved in configuring, monitoring, and tuning
      custom executes queues.

6]. Administrators can configure a set of scheduling guidelines and associate
     them with one or more applications, or with particular application components.

For example,
  
you  can associate one set of scheduling guidelines for one application, and another  
  set of guidelines for other application. At run-time, WebLogic Server uses these
  guidelines to assign  pending work and enqueued requests to execution threads.


7] .

Work Managers can be configured at the domain level, application level, and module level in one of the following configuration files:
  • config.xml—Work Managers specified in config.xml can be assigned to any application, or application component, in the domain. You can use the Administration Console to define a Work Manager.
  • weblogic-application.xml—Work Managers specified at the application level in can be assigned to that application, or any component of that application.
  • weblogic-ejb-jar.xml or weblogic.xml—Work Managers specified at the component-level can be assigned to that component.
  • weblogic.xml—Work Managers specified for a Web Application.
Work Manager Stanza
<work-manager>
<name>highpriority_workmanager</name>
   <fair-share-request-class>
      <name>high_priority</name>
      <fair-share>100</fair-share>
   </fair-share-request-class>
   <min-threads-constraint>
      <name>MinThreadsCountFive</name>
      <count>5</count>
</work-manager>
To reference the Work Manager listed above in the dispatch policy of a Web Application, add the below code into the Web Application's web.xml file:
Referencing the Work Manager in a Web Application
<init-param>
   <param-name>dispatch-policy</param-name>
   <param-value>highpriority_workmanager</param-value>
</init-param>

8]  To manage work in your applications, you define one or more of the following Work Manager 
     components:

  • Fair Share Request Class:
  • Response Time Request Class:
  • Min Threads Constraint:
  • Max Threads Constraint:
  • Capacity Constraint
  • Context Request Class:


  • fair-share-request-class—Specifies the average percentage of thread-use time required to process requests.
For example, assume that WebLogic Server is running two modules. The Work Manager for ModuleA specifies a fair-share-request-class of 80 and the Work Manager for ModuleB specifies afair-share-request-class of 20.
During a period of sufficient demand, with a steady stream of requests for each module such that the number requests exceed the number of threads, WebLogic Server will allocate 80% and 20% of the thread-usage time to ModuleA and ModuleB, respectively.
  • response-time-request-class—This type of request class specifies a response time goal in milliseconds. Response time goals are not applied to individual requests. Instaead, WebLogic Server computes a tolerable waiting time for requests with that class by subtracting the observed average thread use time from the response time goal, and schedules schedule requests so that the average wait for requests with the class is proportional to its tolerable waiting time.

For example, given that ModuleA and ModuleB in the previous example, have response time goals of 2000 ms and 5000 ms, respectively, and the actual thread use time for an individual request is less than its response time goal. During a period of sufficient demand, with a steady stream of requests for each module such that the number requests exceed the number of threads, and no "think time" delays between response and request, WebLogic Server will schedule requests for ModuleA and ModuleB to keep the average response time in the ratio 2:5. The actual average response times for ModuleA and ModuleB might be higher or lower than the response time goals, but will be a common fraction or multiple of the stated goal. For example, if the average response time for ModuleA requests is 1,000 ms., the average response time for ModuleB requests is 2,500 ms.
  • context-request-class—This type of request class assigns request classes to requests based on context information, such as the current user or the current user's group.

  • max-threads-constraintThis constraint limits the number of concurrent threads executing requests from the constrained work set. The default is unlimited. For example, consider a constraint defined with maximum threads of 10 and shared by 3 entry points. The scheduling logic ensures that not more than 10 threads are executing requests from the three entry points combined.
max-threads-constraint can be defined in terms of a the availability of resource that requests depend upon, such as a connection pool.
max-threads-constraint might, but does not necessarily, prevent a request class from taking its fair share of threads or meeting its response time goal. Once the constraint is reached the server does not schedule requests of this type until the number of concurrent executions falls below the limit. The server then schedules work based on the fair share or response time goal.
  • min-threads-constraintThis constraint guarantees a number of threads the server will allocate to affected requests to avoid deadlocks. The default is zero. A min-threads-constraint value of one is useful, for example, for a replication update request, which is called synchronously from a peer.

min-threads-constraint might not necessarily increase a fair share. This type of constraint has an effect primarily when the server instance is close to a deadlock condition. In that case Then, however, it the constraint will cause WebLogic Server to schedule a request from a even if requests in the service class have gotten more than its fair share recently.
  • capacityThis constrain causes the server to reject requests only when it has reached its capacity. The default is zero. Note that the capacity includes all requests, queued or executing, from the constrained work set. Work is rejected either when an individual capacity threshold is exceeded or if the global capacity is exceeded. This constraint is independent of the global queue threshold.










Wednesday, 27 October 2010

Performance Tuning Part - 2


Performance tuning WebLogic Server and your WebLogic Server application is a complex and iterative process. 

Tuning allows you to adjust resources to achieve your performance objectives.

The following sections provide a tuning roadmap and tuning tips for you can use to improve system performance.

****************************************************************************************************
1.  Understand Your Performance Objectives

2.  Measure Your Performance Metrics
      2.1. Monitor Disk and CPU Utilization

      2.2. Monitor Data Transfers Across the Network

3.  Locate Bottlenecks in Your System

4.  Minimize Impact of Bottlenecks
  • Tune Your Application
  • Tune your DB
  • Tune WebLogic Server Performance Parameters
  • Tune Your JVM
  • Tune the Operating System
  • Tuning the WebLogic Persistent Store
5.  Capacity Planning

****************************************************************************************************

Understand Your Performance Objectives

To determine your performance objectives, you need to understand the application deployed and the environmental constraints placed on the system. Gather information about the levels of activity that components of the application are expected to meet, such as:
§  The anticipated number of users.
§  The number and size of requests.
§  The amount of data and its consistency.
§  Determining your target CPU utilization.
Your target CPU usage should not be 100%, you should determine a target CPU utilization based on your application needs, including CPU cycles for peak usage. If your CPU utilization is optimized at 100% during normal load hours, you have no capacity to handle a peak load. In applications that are latency sensitive and maintaining the ability for a fast response time is important, high CPU usage (approaching 100% utilization) can reduce response times while throughput stays constant or even increases because of work queuing up in the server. For such applications, a 70% - 80% CPU utilization recommended. A good target for non-latency sensitive applications is about 90%.

Performance objectives are limited by constraints, such as

§  The configuration of hardware and software such as CPU type, disk size vs. disk speed, sufficient memory.
There is no single formula for determining your hardware requirements. The process of determining what type of hardware and software configuration is required to meet application needs adequately is called capacity planning. Capacity planning requires assessment of your system performance goals and an understanding of your application. Capacity planning for server hardware should focus on maximum performance requirements.
        • The ability to interoperate between domains, use legacy             systems, support legacy data.
§  Development, implementation, and maintenance costs.
You will use this information to set realistic performance objectives for your application environment, such as response times, throughput, and load on specific hardware.
Measure Your Performance Metrics
After you have determined your performance criteria as described above take measurements of the metrics you will use to quantify your performance objectives.


Monitor Disk and CPU Utilization

Run your application under a high load while monitoring the:

§  Application server (disk and CPU utilization)
§  Database server (disk and CPU utilization)
The goal is to get to a point where the application server achieves your target CPU utilization. If you find that the application server CPU is under utilized, confirm whether the database is bottle necked. If the database CPU is 100 percent utilized, then check your application SQL calls query plans. For example, are your SQL calls using indexes or doing linear searches? Also, confirm whether there are too manyORDER BY clauses used in your application that are affecting the database CPU. 
If you discover that the database disk is the bottleneck (for example, if the disk is 100 percent utilized), try moving to faster disks or to a RAID (redundant array of independent disks) configuration, assuming the application is not doing more writes then required.

Once you know the database server is not the bottleneck, determine whether the application server disk is the bottleneck. Some of the disk bottlenecks for application server disks are:

§  Persistent Store writes
§  Transaction logging (tlogs)
§  HTTP logging
§  Server logging
The disk I/O on an application server can be optimized using faster disks or RAID, disabling synchronous JMS writes, using JTA direct writes for tlogs, or increasing the HTTP log buffer.
Monitor Data Transfers Across the Network
Check the amount of data transferred between the application and the application server, and between the application server and the database server. This amount should not exceed your network bandwidth; otherwise, your network becomes the bottleneck.

Locate Bottlenecks in Your System

If you determine that neither the network nor the database server is the bottleneck, start looking at your operating system, JVM, and WebLogic Server configurations. Most importantly, is the machine running WebLogic Server able to get your target CPU utilization with a high client load? If the answer is no, then check if there is any locking taking place in the application. You should profile your application using a commercially available tool (for example, JProbe or OptimizeIt) to pinpoint bottlenecks and improve application performance.
Tip: Even if you find that the CPU is 100 percent utilized, you should profile your application for performance improvements.

Minimize Impact of Bottlenecks

you tune your environment to minimize the impact of bottlenecks on your performance objectives. It is important to realize that in this step you are minimizing the impact of bottlenecks, not eliminating them. Tuning allows you to adjust resources to achieve your performance objectives.
Tune Your Application
Tune your DB
Tune WebLogic Server Performance Parameters
Tune Your JVM
Tune the Operating System
 Capacity Planning
The process of determining what type of hardware and software configuration is required to meet application needs adequately is called capacity planning. Capacity planning is not an exact science. Every application is different and every user behavior is different. 
Capacity Planning Questions
For Information, See:
Is WebLogic Server well-tuned?
Assessing Your Application Performance Objectives
How well-designed is the user application?
Database Server Capacity and User Storage Requirements
Is there enough bandwidth?
Network Load
How many transactions need to run simultaneously?
Concurrent Sessions
Is the database a limiting factor? Are there additional user storage requirements?
Database Server Capacity and User Storage Requirements
What is running on the machine in addition to WebLogic Server?
Network Load
Do clients use SSL to connect to WebLogic Server?
SSL Connections and Performance
What types of traffic do the clients generate?
RMI and Server Traffic
What types of clients connect to the WebLogic Server application?
Programmatic and Web-based Clients
Is your deployment configured for a cluster?
Clustered Configurations

Tuning Tips
This section provides tips and guidelines when tuning overall system performance:
§  Performance tuning is not a silver bullet. Simply put, good system performance depends on: good design, good implementation, defined performance objectives, and performance tuning.
§  Performance tuning is ongoing process. Implement mechanisms that provide performance metrics which you can compare against your performance objectives, allowing you to schedule a tuning phase before your system fails.
§  The object is to meet your performance objectives, not eliminate all bottlenecks. Resources within a system are finite. By definition, at least one resource (CPU, memory, or I/O) will be a bottleneck in the system. Tuning allows you minimize the impact of bottlenecks on your performance objectives.
§  Design your applications with performance in mind:
·       Keep things simple - avoid inappropriate use of published patterns.
·       Apply Java EE performance patterns.
·       Optimize your Java code.