weblogic线程过载保护策略

Below python/WLST script can be used to configure overload protection in weblogic server using WLST tool.

connect ('weblogic','weblogic','t3://tpaste.com:9001');
edit()
startEdit(true)
print('List Servers...')
cd ("/Servers")
ServerName=ls('/Servers',returnMap='true')
for domn in ServerName:
server=cmo.lookupServer(domn)
overload=server.getOverloadProtection()
overload.setFailureAction('force-shutdown')
failureTrigger = overload.getServerFailureTrigger()
if failureTrigger == None:
failureTrigger=overload.createServerFailureTrigger()

failureTrigger.setStuckThreadCount(25)

server.setAutoRestart(true)
server.setRestartIntervalSeconds(3600)
server.setRestartDelaySeconds(10)
server.setRestartMax(20)
save()
activate()
disconnect()

More on Configuring WebLogic Server to Avoid Overload Conditions

When system capacitiy is reached, if an application server continues to accept requests, application performance and stability can deteriorate. The following sections demonstrate how you can configure WebLogic Server to minimize the negative results of system overload.


Limiting Requests in the Thread Pool

In WebLogic Server, all requests, whether related to system administration or application activity—are processed by a single thread pool. An administrator can throttle the thread pool by defining a maximum queue length. Beyond the configured value, WebLogic Server will refuse requests, except for requests on administration channels.
Note: Administration channels allow access only to administrators. The limit you set on the execute length does not effect administration channel requests, to ensure that reaching the maximum thread pool length does not prevent administrator access to the system. To limit the number of administration requests allowed in the thread pool, you can configure an administration channel, and set the MaxConnectedClients attribute for the channel.

When the maximum number of enqueued requests is reached, WebLogic Server immediately starts rejecting:

Web application requests.
Non-transactional RMI requests with a low fair share, beginning with those with the lowest fair share.

If the overload condition continues to persist, higher priority requests will start getting rejected, with the exception of JMS and transaction-related requests, for which overload management is provided by the JMS and the transaction manager.

Throttle the thread pool by setting the Shared Capacity For Work Managers field in the Administration Console (see Environments > Servers > Threads and select an execute queue). The default value of this field is 65536.

Work Managers and Thread Pool Throttling

An administrator can configure Work Managers to manage the thread pool at a more granular level, for sets of requests that have similar performance, availability, or reliability requirements. A Work Manager can specify the maximum requests of a particular request class that can be queued. The maximum requests defined in a Work Manager works with global thread pool value. The limit that is reached first is honored.

Limiting HTTP Sessions

An administrator can limit the number of active HTTP sessions based on detection of a low-memory condition. This is useful in avoiding out of memory exceptions.

WebLogic Server refuses requests that create new HTTP sessions after the configured threshold has been reached. In a WebLogic Server cluster, the proxy plug-in redirects a refused request to another Managed Server in the cluster. A non-clustered server instance can re-direct requests to alternative server instance.

The servlet container takes one of the following actions when maximum number of sessions is reached:

If the server instance is in a cluster, a the servlet container throws a SessionCreationException. Your application code should handle this runtime exception and send a relevant response.

To implement overload protection, you should handle this exception and send a 503 response explicitly. This response can then be handled by the proxy or load balancer.

You set a limit for the number of simultaneous HTTP sessions in the deployment descriptor for the Web Application. For example, the following element sets a limit of 12 sessions:

<session-descriptor>
<max-in-memory-sessions>12</max-in-memory-sessions>
</session-descriptor>

Exit on Out of Memory Exceptions

Administrators can configure WebLogic Server to exit upon an out of memory exception. This feature allows you to minimize the impact of the out of memory condition—automatic shutdown helps avoid application instability, and you can configure Node Manager or another HA tool to automatically restart WebLogic Server, minimizing down-time.

You can configure this using the Administration Console, or by editing the following elements in config.xml:

<overload-protection>
<panic-action>system-exit</panic-action>
</overload-protection>

Stuck Thread Handling

WebLogic Server checks for stuck threads periodically. If all application threads are stuck, a server instance marks itself failed, if configured to do so, exits. You can configure Node Manager or a third-part high-availability solution to restart the server instance for automatic failure recovery.

You can configure these actions to occur when not all threads are stuck, but the number of stuck threads have exceeded a configured threshold,

Shut down the Work Manager if it has stuck threads. A Work Manager that is shut down will refuse new work and reject existing work in the queue by sending a rejection message. In a cluster, clustered clients will fail over to another cluster member.
Shut down the application if there are stuck threads in the application. The application is shutdown by bringing it into admin mode. All Work Managers belonging to the application are shut down, and behave as described above.
Mark the server instance as failed and shut it down it down if there are stuck threads in the server. In a cluster, clustered clients that are connected or attempting to connect will fail over to another cluster member.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值