欢迎来到天天文库
浏览记录
ID:9302553
大小:52.00 KB
页数:6页
时间:2018-04-27
《was宕机常见问题及参考解决方案》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、WAS宕机问题总结起来有以下几类:一、线程挂起导致线程池满(ThreadHang):HangsrefertotheJVMlockinguporrefusingtorespond.Ahangcanoccurwhen:1)Yourapplicationenteredanwaitleak2)ExcessiveSynchronizationcauseperformanceproblems3)Adeadlockhasoccurred收集日志:生成JAVACORE分析工具:IBMThreadandMonitorDumpAnalyzer1、线程等待泄漏(W
2、aitLeaks)常见的情况就是,有很多线程使用wait()方法,等待被唤醒notify()。但是,存在某一个线程获取到锁并且进行业务处理完成后,忘记去唤醒等待执行的进程。这样导致的等待泄漏,从而线程挂起。Whenyouusethewait/notifymechanism,youtypicallyhaveoneormorethreadsblockedinthewait()call,waitingtobenotified.Thenotifyingthreadissupposedtocallnotify()ornotifyAll()tosigna
3、lthatwaitingthreadscanwakeupandcarryonprocessing.Aproblmaticsituationcouldoccurthatthenotify()callisinvokedbeforethethreadsgointothewait()method.Inthiscase,thewaitingthreadswouldnotbenotifiedanymoreandbecomestuck.So,donotforgettonotifythewaitingtheadsinyouapplicationandmaks
4、surethattheNotifyactionisperformedafterallthewaitingthreadsarestarted.应对策略:notify必须发生在所有wait之前。2、同步过度(ExcessiveSynchronization)LIS系统FORMULAONE报表打印就是采用了SYNCHRONIZE思想,如果有某一个大的报表长时间打不出来的话,会导致其它所有的报表打印线程全部挂起。Synchronizationisrequiredforprotectingsomecriticalresources,butiflarge
5、sectionsofcodearesynchronized,anapplicationeffectivelywillbecomesinglethreaded,andthethroughputwilldecreasedramatically.Toimprovetheperformance,youshouldthinkabout:1)Useotherefficientalgorithmtoreplacethemonitor/lock?2)Trytokeepthemonitorlockforashorttime?3)Reducethenumbero
6、fthreadsusingthismonitor/lock?应对策略:改变程序实现算法,避免占用锁时间过长。比如设置多个锁或者提高同步代码块的执行效率。3、资源抢占死锁(DeadLock)线程运行需要获取到两个资源,当线程1获取到资源A,线程2获取到资源B,此时,线程1需要再获取资源B,线程2需要再获取资源A。这就形成了资源循环申请的一个死锁。其它想获取到资源A或者资源B的线程必将都会挂起。Inthiscase,athreadacquiresthelockonlock1,Atthesametime,anotherthreadacquirest
7、helockonlock2.sothethreadsaredeadlocked:neitherthreadwillgiveupitslockuntilitacquirestheotherlock,butneitherwillbeabletoacquiretheotherlockuntiltheotherthreadgivesitup.Oneofthebestwaystopreventthepotentialfordeadlockistoavoidacquiringmorethanonelockatatime,whichisoftenpract
8、ical.However,ifthatisnotpossible,youneedastrategythatensuresyouacquiremultiplelock
此文档下载收益归作者所有