WAS宕机常见问题及参考解决方案.docx

上传人:b****1 文档编号:2417858 上传时间:2022-10-29 格式:DOCX 页数:7 大小:19.31KB
下载 相关 举报
WAS宕机常见问题及参考解决方案.docx_第1页
第1页 / 共7页
WAS宕机常见问题及参考解决方案.docx_第2页
第2页 / 共7页
WAS宕机常见问题及参考解决方案.docx_第3页
第3页 / 共7页
WAS宕机常见问题及参考解决方案.docx_第4页
第4页 / 共7页
WAS宕机常见问题及参考解决方案.docx_第5页
第5页 / 共7页
点击查看更多>>
下载资源
资源描述

WAS宕机常见问题及参考解决方案.docx

《WAS宕机常见问题及参考解决方案.docx》由会员分享,可在线阅读,更多相关《WAS宕机常见问题及参考解决方案.docx(7页珍藏版)》请在冰豆网上搜索。

WAS宕机常见问题及参考解决方案.docx

WAS宕机常见问题及参考解决方案

WAS宕机常见问题及参考解决方案

WAS宕机问题总结起来有以下几类:

一、线程挂起导致线程池满(ThreadHang):

HangsrefertotheJVMlockinguporrefusingtorespond.

Ahangcanoccurwhen:

1)Yourapplicationenteredanwaitleak

2)ExcessiveSynchronizationcauseperformanceproblems

3)Adeadlockhasoccurred

收集日志:

生成JAVACORE

分析工具:

IBMThreadandMonitorDumpAnalyzer

1、线程等待泄漏(WaitLeaks)

常见的情况就是,有很多线程使用wait()方法,等待被唤醒notify()。

但是,存在某一

个线程获取到锁并且进行业务处理完成后,忘记去唤醒等待执行的进程。

这样导致的等待

泄漏,从而线程挂起。

Whenyouusethewait/notifymechanism,youtypicallyhaveoneormorethreadsblockedinthewait()call,waitingtobenotified.Thenotifyingthreadissupposedtocallnotify()ornotifyAll()tosignalthatwaitingthreadscanwakeupandcarryonprocessing.

Aproblmaticsituationcouldoccurthatthenotify()callisinvokedbeforethethreadsgointothewait()method.Inthiscase,thewaitingthreadswouldnotbenotifiedanymoreandbecomestuck.

So,donotforgettonotifythewaitingtheadsinyouapplicationandmakssurethattheNotifyactionisperformedafterallthewaitingthreadsarestarted.

应对策略:

notify必须发生在所有wait之前。

2、同步过度(ExcessiveSynchronization)

LIS系统FORMULAONE报表打印就是采用了SYNCHRONIZE思想,如果有某一个大的报表长时间

打不出来的话,会导致其它所有的报表打印线程全部挂起。

Synchronizationisrequiredforprotectingsomecriticalresources,butiflargesectionsofcodearesynchronized,anapplicationeffectivelywillbecomesinglethreaded,andthethroughputwilldecreasedramatically.Toimprovetheperformance,youshouldthinkabout:

1)Useotherefficientalgorithmtoreplacethemonitor/lock?

2)Trytokeepthemonitorlockforashorttime?

3)Reducethenumberofthreadsusingthismonitor/lock?

应对策略:

改变程序实现算法,避免占用锁时间过长。

比如设置多个锁或者提高同步代码

块的执行效率。

3、资源抢占死锁(DeadLock)

线程运行需要获取到两个资源,当线程1获取到资源A,线程2获取到资源B,此时,线程1需

要再获取资源B,线程2需要再获取资源A。

这就形成了资源循环申请的一个死锁。

其它想获

取到资源A或者资源B的线程必将都会挂起。

Inthiscase,athreadacquiresthelockonlock1,Atthesametime,anotherthreadacquiresthelockonlock2.sothethreadsaredeadlocked:

neitherthreadwillgiveupitslockuntilitacquirestheotherlock,butneitherwillbeabletoacquiretheotherlockuntiltheotherthreadgivesitup.

Oneofthebestwaystopreventthepotentialfordeadlockistoavoidacquiringmorethanonelockatatime,whichisoftenpractical.However,ifthatisnotpossible,youneedastrategythatensuresyouacquiremultiplelocksinaconsistent,definedorder.

应对策略:

申请资源锁,按顺序申请,或者一次性全部申请。

二、CPU使用率高(HighCPUUsage):

HighCPUusageproblemrefertothatasystemisperformingpoorlybecauseoflackofCPUresources.

AhighCPUusageproblemcanoccurwhen:

1)SomethreadsconsumingalotofCUPresources

2)AfrequentGCprobelmoccurs

1、程序自身耗用高CPU(比如:

InfiniteLoop)

收集日志:

生成JAVACORE

分析工具:

操作系统监控工具(比如TOPASPS之类的)IBMThreadandMonitorDump

Analyzer

应对策略:

调整程序,改变算法,使得最终耗用较少CPU资源。

2、频繁垃圾回收(FrequentGC)

多次循环,去申请很多的小对象。

从而需要垃圾回收器去频繁释放很小的内存空间。

ItisrecommendedthatusersenabletheVerobseGCfirstandthePmatorGCVMwillbehelpfultofindoutthefrequentGC.

Heapdumptellsyoutheobjectsinfoofjavaheapwhenitistriggered.YoucanuseHeapdumpstodebugthejavaheapissues.Youcanpressthe"Tool-GenerateDump"menutotrigeraheapdumpwhichwillshowobjectsinformation.

收集日志:

打开详细垃圾回收,生成HEAPDUMP

分析工具:

(IBMSupportAssistant)MemoryDumpDiagnosticforJava(MDD4J)

应对策略:

调整垃圾回收策略,或者改变算法,调整程序,把很多局部变量(小对象)全

局化。

三、内存溢出(OutOfMemory):

TheJVMmaintainstwomemoryareas,theJavaheap,andthenative(orsystem)heap.Thesetwoheapshavedifferentpurposes,aremaintainedbydifferentmechanisms,andarelargelyindependentofeachother.

OutOfMemoryconditionthatoccurscouldbeduetoeitherrunningoutofJavaheaporNativeheap.

1、本地内存溢出(NativeOOM)

收集日志:

生成系统宕机日志(systemdump)

OSmonitortools,suchas"Svmon","top","vmstat"andsoon分析工具:

(IBMSupportAssistant)DumpAnalyzer

应对策略:

暂时无。

2、finalize执行时间过长(BlockedinFinalize)

程序员自己写finalize的处理代码,导致执行时间过长,从而影响JVM的高效垃圾回收处理

策略。

最终内存被占满。

TheJavaserviceteamrecommendsthatapplicationsavoidtheuseoffinalizersifpossible.

TheJVMspecificationstatesthatfinalizersareforemergencyclear-upof,forexample,hardwareresources.Theserviceteamrecommendsthatyouusefinalizersforthispurposeonly.

DonotusethemtocleanupJavasoftwareresourcesorforclosedownprocessingoftransactions.Becauseitwillaffectthegarbagecollection,andmaycauseamemoryproblem.

Finalizersareanexpensiveuseofcomputerresourcesandtheyarenotdependable.

TheJavaserviceteamdoesnotrecommendthatyouusefinalizersforprocesscontrol

orfortidyingJavaresources.Infact,usefinalizersaslittleaspossible.

FortidyingJavaresources,considertheuseofacleanuproutine.Whenyouhave

finishedwithanobject,calltheroutinetonulloutallreferences,deregisterlisteners,clearouthashtables,andothercleanupoperat

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 求职职场 > 面试

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1