Tech

20120806

Weblogic Server Thread pool, from my view.


Weblogic Server has two different way of handling Thread pools: 

Weblogic 8.1 Thread Pool Model

The process was performed in multiple execute queues. Different types of work were handle in different queue, basing on priority and ordering requirements to avoid dead lock. The tuning on this model is very manual and dependent on the administrator analyses and configuration to get some real performance. The control of thread was basically changing the number of threads in the default queue, or configure custom execute queues to a particular applications to have access to a fixed number of execute thread. Oracle /BEA recommends migrating to Work Manager. 

How to enable

- The configuration to use the 8.1 is not trivial as configuring from console; As mentioned above the recommendation is to use the Work Manager, since this style is very prone to human bad tune configuration. I mean, system resources changes constantly just by adding  a new program or changing parameters, maybe a good tune on a system and a small change happens you could face some performance degradation. 

1. Shut down the WLS's java instance. 
2. Edit the config.xml, by adding the use use81-style-execute-queues element to true. 
3. Start a new WLS's java instance. 
4. Explicitly create the weblogic.kernel.Default execute queue from the Console.
5. Reboot the WLS's server java instance. 

<server>
   <name>YourServer
n
</name>
   <ssl>
      <name>myserver</name>
      <enabled>true</enabled>
      <listen-port>7002</listen-port>
   </ssl>
   <use81-style-execute-queues>true</use81-style-execute-queues>
   <listen-address/>
</server>

*You might need to do the same steps for each server. 

Tuning 

The ThreadCount of the element ExecuteQueue set in the config.xml equals the number of simultaneous operations that can be performed by an application assign to the execute queue. Threads consume resources, and having too many as consequence can have a lot physical resources unnecessary use for unnecessary work. Therefore could decrease performance of the application as for the entire system. 

The ThreadCount can be different depending in what type of Mode that you start the WLS: 

Development: Mainly use to load test and development environment, this could mean that WLS can have more I/Os and other types of issues while using this mode. This mode is mainly to stress the application container it self and the default number of thread is 15

Production: As named this mode should be use for production. Changes are not on the fly, and usually the application server needs some extra steps, lock edit is one of the example; This mode is for performance, and passing on the stress to the environment system and the default value of thread is 25

*Some cases, depending on large cluster and configuration, just by changing the mode on the WLS from Development to Production you can face some performance degradation on your environment. Simple math, with default 8.1 configuration: 
10 instances of Development mode, equals to 150 threads to share the system resources. 
10 instances of Production mode, equals to 250 threads to share the system resources. 

Simple tuning of thread could resolve this issue; I would disregard having the Porduction mode being remove from an production environment. Check some scenarios for Modifying the default thread count: 

(You need to understand the nature of your business, some applications has a pick time of usage at the end of every month; example: banking, after you getting your salary).

Thread Count < numbers of CPUs :
  • Behavior _  CPUs are not being fully use on a pick time, but there is some work to be done.
  • Possible Action _ Increase the thread count. 

Thread Count == number of CPUs: 
  • Behavior _ CPUs are not being fully use on a pick time, but there is some work to be done.
  • Possible Action _ Increase the thread count. 

Thread Count > number of CPUs (by a moderate number of threads)
  • Behavior _  CPUs are being fully use on a pick time, with a moderate amount of context switching.
  • Possible Action _  Tune the thread count, and test performance. 

Thread Count > number of CPUs (by a large number of threads)
  • Behavior _  CPUs are being fully use on a pick time, with many context switching.
  • Possible Action _ Reduce the number of threads. (remember my example of Modes above...)



Work Manager

Is a single thread pool, where all types of work are executed. The tuning of an Work Manager is by demand, in which means that it happens automatically. Queue monitors the throughput base on history and determines the adjust of thread count. The work is base on defined rules, runtime metrics (history) to avoid deadlocks. This the WLS passes it on some of  the tuning responsibility from the administrators to it self. 

Administrator can manage work by configuring some types of scheduling guideline by defining some components: 

  • Fair Share Request Class
    Specifies the average time required to process a request. Default is 50. (This is base on percentage, therefore timing also will depend on the environment physical capacity to process).
  • Response Time Request Class
    Is the response time goal in milliseconds. Not applied to individual request. 
  • Min Threads Constrains
    The guarantee  number of threads the server will allocate. Default is Zero. 
  • Max Threads Constraint
    Limit the number of concurrent threads. Default is unlimited, -1. 
  • Capacity Constraint
    Forces the server to reject request when reached its capacity, either individual or global capacity is exceeded it will reject requests. The default is unlimited, -1. 
  • Context Request Class
   Assigns request classes depending on context information. 
WLS works as best effort, this means will no guarantee that configured ratio will be maintained. Its behavior can possible change depending on demand.

ref: http://docs.oracle.com/cd/E21764_01/web.1111/e13814/appb_queues.htm
ref: http://docs.oracle.com/cd/E24329_01/web.1211/e24432/self_tuned.htm#i1068066

Important: This information is based on my personal understanding of Oracle's documentation. Please refer to Oracle's documentation for further information and tuning. Remember that you as an administrator is responsible for the best tuning of your own environment. Simple word, use your gut instincts! if you have some problem with this please read the article written by Leon Watson from MailOnline:
"Researches say our first thought is often our best" 
ref: http://www.dailymail.co.uk/news/article-2031848/Why-right-trust-gut-instincts-Scientists-discover-decision-IS-right-one.html

No comments:

Post a Comment