美文网首页
WEB应用访问缓慢的问题定位

WEB应用访问缓慢的问题定位

作者: 85年的大喇叭 | 来源:发表于2021-07-08 11:38 被阅读0次

WEB应用访问缓慢的问题定位

欢迎关注博主公众号「java大师」, 专注于分享Java领域干货文章, 关注回复「资源」, 免费领取全网最热的Java架构师学习PDF, 转载请注明出处 http://www.javaman.cn/jszw/web-slow

1、如果页面能正常访问,但是每个页面的打开速度都很慢,处理方式如下:

1)首先查看应用服务器和数据库服务器的cpu和内存使用情况是不是很高

windows服务器通过任务管理器查看

windows截图-1.png

linux服务器通过top命令查看内存和cpu使用率:主要看1、2、3这三个指标有没有异常,内存和cpu有没有超过95%

linux截图-2.png

详细参数参见下了文档

Linux查看CPU和内存使用情况:https://www.cnblogs.com/mengchunchen/p/9669704.html

2)如果两个服务器的内存都不高,通过下面语句找到oracle等待时长最多的sql带入plsql进行验证

<pre class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" spellcheck="false" lang="sql" cid="n13" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 0px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> SELECT ASH.USER_ID,
U.USERNAME,
S.SQL_TEXT,
SUM(ASH.WAIT_TIME + ASH.TIME_WAITED) TTL_WAIT_TIME
FROM VACTIVE_SESSION_HISTORY ASH, VSQLAREA S, DBA_USERS U
WHERE ASH.SAMPLE_TIME BETWEEN SYSDATE - 15 / (24 * 60) AND SYSDATE
AND ASH.SQL_ID = S.SQL_ID
AND ASH.USER_ID = U.USER_ID
GROUP BY ASH.USER_ID, S.SQL_TEXT, U.USERNAME
ORDER BY TTL_WAIT_TIME</pre>

plsql验证

将sql放入plsql窗口,按【F5】进入执行计划页面

oracle执行计划分析-4.png

cost为耗费时长,执行顺序是按照缩进从右往左,从上到下执行,上图执行顺序为table access full--> table access full-->hash join-->all rows。如果一个列表查询的sql执行的cost耗费越大,结合oracle等待时长的sql,可以断定该sql存在问题!!!

将定位的sql提交给研发进行进一步的分析!!

目前发现数据库表中的部分索引建立以后失效的情况,经分析定位为:随着表的增长,where条件出来的数据太多,大于15%,使得索引失效,目前无法提前发现,只能通过上面的语句定位到执行缓慢的语句。

附录----执行计划详解:https://www.cnblogs.com/Dreamer-1/p/6076440.html

3)如果没有找到等待过长的sql语句,需要进一步排查应用服务器到oracle数据库主机的连接是否顺畅,有没有存在延迟!!

3.1)oracle的alert的日志文件超过4G,会导致连接报错

可以通过下列语句找到alert.log的目录

<pre class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" spellcheck="false" lang="sql" cid="n27" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 0px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> select value from v$diag_info where name ='Diag Trace';</pre>

[图片上传失败...(image-28f6a4-1625715500143)]

找到该日志,然后备份删除

[图片上传失败...(image-d134d2-1625715500143)]

3.2)如果日志文件没有超过4G或者3.1步骤处理完仍然没有解决数据库连接超时或者慢的问题

需要执行:tnsping IP:端口/实例名称

<pre class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n33" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 0px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> C:\Users\fangr>tnsping localhost:1521/orcl
TNS Ping Utility for 64-bit Windows: Version 11.2.0.1.0 - Production on 03-7月 -2021 17:08:45

Copyright (c) 1997, 2010, Oracle. All rights reserved.

已使用的参数文件:
D:\app1\fangr\product\11.2.0\dbhome_1\network\admin\sqlnet.ora

已使用 EZCONNECT 适配器来解析别名
尝试连接 (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=orcl))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
OK (0 毫秒)</pre>

执行结果如下图:如果超过1000毫秒,则连接可能存在问题!!需要协调ping一下是否丢包,或者协调客户定位下网络问题

oracle-tnsping-6.png

扩展:AWR分析报告进行数据库的分析

觉得数据库慢的时候也可以通过AWR分析报告,对oracle进行性能分析找到一些oracle可能存在的潜在问题

对数据库缓慢时间段范围内生成awr报告!!

AWR报告生成方法:https://www.cnblogs.com/liyasong/p/oracle_report1.html

AWR报告详细解读:https://blog.csdn.net/u011334954/article/details/103953103?utm_medium=distribute.pc_relevant.none-task-blog-baidujs_baidulandingword-0&spm=1001.2101.3001.4242

该报告重点关注如下内容:

1)正常情况下DBCPU应该排在首位,%DB time每个耗时不能超过70%,如果超过就要针对处理!

awr报告分析7-1.png

2)根据SQL ordered by Elapsed Time,找到耗时比较长的sql,针对sql进行分析

awr报告分析7-2.png

3)查看SGA和PGA的内存使用是否过高,正常情况下不得超过主机内存的80%

awr-分析报告3

2、如果页面能正常访问,添加记录或者更新网页卡住不动:

网页访问和列表加载正常,此刻很有可能存在oracle锁表的情况,通过下面的sql执行,找到被锁的表

<pre class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" spellcheck="false" lang="sql" cid="n53" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 0px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> select sess.sid,
sess.serial#,
lo.oracle_username,
lo.os_user_name,
ao.object_name,
lo.locked_mode
from vlocked_object lo, dba_objects ao, vsession sess
where ao.object_id = lo.object_id
and lo.session_id = sess.sid;</pre>

找到被锁的表

oracle锁表7-4.png

通过下面sql定位到锁表的sql语句

<pre class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" spellcheck="false" lang="sql" cid="n57" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 0px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> SELECT A.USERNAME,
A.MACHINE,
A.PROGRAM,
A.SID,
A.SERIAL#,
A.STATUS,
C.PIECE,
C.SQL_TEXT
FROM VSESSION A, VSQLTEXT C
WHERE A.SID IN (SELECT DISTINCT T2.SID
FROM VLOCKED_OBJECT T1, VSESSION T2
WHERE T1.SESSION_ID = T2.SID)
AND A.SQL_ADDRESS = C.ADDRESS(+)
ORDER BY C.PIECE;</pre>

将找到的sql提交给研发,判断该sql语句是人为锁定的还是程序未提交导致的!

[图片上传失败...(image-800f18-1625715500143)]

如果需要,可以通过下面的sql进行解锁

<pre class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" spellcheck="false" lang="sql" cid="n61" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 0px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> alter system kill session '68,51'; --分别为SID和SERIAL#号</pre>

3、如果排除oracle和sql的问题,那么进一步排查应用服务器的问题

1)调整程序连接的最大线程数和排队请求数

tomcat:将maxThreads="800" acceptCount="1000"调整为800和500代表允许最大线程数为800,可以同时处理800个请求,如果超 过800个线程,接受排队500个请求!

<pre class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" spellcheck="false" lang="xml" cid="n67" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 0px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" maxThreads="800" acceptCount="500"/></pre>

weblogic:

<pre class="md-fences md-end-block md-fences-with-lineno ty-contain-cm modeLoaded" spellcheck="false" lang="" cid="n69" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: normal; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 0px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;"> 进入WebLogic控制台——左边窗口的mydomain——servers——点击myserver——Configuration——General——点击Advanced Options的Show链接——最下面的Configure Execute Queues 链接——weblogic.kernel.Default链接——Thread Count参数。的却是隐藏的比较深。修改Thread Count的值,然后重启WebLogic就可以生效了。</pre>

2)根据服务器的内存大小,调整tomcat的内存,最大不超过应用服务器内存的60%

tomcat:

<pre class="md-fences mock-cm md-end-block md-fences-with-lineno" spellcheck="false" lang="shell" cid="n72" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 8px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">在“echo"UsingCATALINA_BASE: $CATALINA_BASE"”上面加入以下行:
JAVA_OPTS="-server -Xms800m -Xmx800m -XX:PermSize=256m -XX:MaxPermSize=512m -XX:MaxNewSize=512m"</pre>

<pre class="md-fences mock-cm md-end-block md-fences-with-lineno" spellcheck="false" lang="" cid="n73" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 8px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">weblogic:</pre>

<pre class="md-fences mock-cm md-end-block md-fences-with-lineno" spellcheck="false" lang="" cid="n74" mdtype="fences" style="box-sizing: border-box; overflow: visible; font-family: var(--monospace); font-size: 0.9em; display: block; break-inside: avoid; text-align: left; white-space: pre-wrap; background-image: inherit; background-position: inherit; background-size: inherit; background-repeat: inherit; background-attachment: inherit; background-origin: inherit; background-clip: inherit; background-color: rgb(248, 248, 248); position: relative !important; margin-bottom: 15px; margin-top: 15px; padding-top: 8px; padding-bottom: 6px; padding-left: 8px; width: inherit; color: rgb(51, 51, 51); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">直接修改user_projects\domains\base_domain\bin下的startWebLogic.cmd文件

在它下面添加一下代码

set JAVA_OPTIONS=-Xms256m –Xmx256m;</pre>

3)根据tomcat的catalina.log的具体报错反馈给开发进行查询,需要根据的实际报错

4)服务器重启大法

相关文章

  • WEB应用访问缓慢的问题定位

    WEB应用访问缓慢的问题定位 欢迎关注博主公众号「java大师」, 专注于分享Java领域干货文章, 关注回复「资...

  • PWA(渐进式 Web 应用)

    web 应用体验上不如原生应用 传统 web 应用 依赖网络来加载内容。弱网环境加载慢,离线无法访问等问题 不能添...

  • 01_web_http简介

    一、web应用 Web应用程序是一种可以通过Web访问的应用程序,程序的最大好处是用户很容易访问应用程序,用户只需...

  • 0424-web:MVC/spring-mvc

    web应用的功能分解(mvc):交互界面(jsp),资源/方法定位(route)与调用,数据库访问与修改(serv...

  • Vue的性能优化

    定位应用的性能问题 Vue应用的性能问题可以分为两个部分:运行时性能问题,加载性能问题。和其他 web应用一样,定...

  • WEB应用

    Web应用程序是什么 Web应用程序是一种可以通过Web访问的应用程序,程序的最大好处是用户很容易访问应用程序,用...

  • Web应用程序

    web应用程序是一种可以通过Web访问的应用程序。Web应用程序最大的好处是永和很容易访问应用程序。用户只需要有浏...

  • 大话设计模式 代理模式

    应用:1.web service 会生成web reference 的文件夹,通过调用代理解决远程访问的问题。2....

  • JAVA Web基础学习---JSP(一)

    Web应用程序是一种可以通过Web访问的应用程序。Web应用程序的一个最大好处是用户很容易访问应用程序。用户只需要...

  • JavaWeb简介

    Web应用程序 什么是Web应用程序?Web应用程序是一种可以通过Web访问的的应用程序。Web应用程序的一个最大...

网友评论

      本文标题:WEB应用访问缓慢的问题定位

      本文链接:https://www.haomeiwen.com/subject/wwozultx.html