使用 Mod_JK 测量 JBoss 服务器上的请求处理时间
我的Web应用程序架构是:Apache 2(作为负载均衡器)+ JBoss 3.2.3 + MySQL 5.0.19。
我想要: 测量仅在 JBoss 服务器上花费的请求处理时间(对于每个单独的请求)(即,不包括在 Web 和数据库服务器上花费的时间。
我一直在研究如何仅在应用程序层上记录请求处理时间我发现 *mod_JK 日志记录*、*Apache 的 mod_log_config* 和 Tomcat AccessLogValve 作为两种可能的方法
使用 *mod_JK 日志记录*:我的理解 mod_jk 日志记录为每个请求提供了请求处理时间。并计算请求离开 Apache 服务器的时间与 Apache 服务器收到相应响应的时间之间的时间差,如果这不准确/正确,请
使用 Apache 的 mod_log_config 模型进行纠正(http://www.lifeenv.gov.sk/tomcat-docs/jk/config/apache.html< /a>): 通过添加LogFormat(JKLogFile 构造)构造中的“%{JK_REQUEST_DURATION}n”(请参阅上面的链接)从 Apache 角度捕获总体 Tomcat 处理时间。
时间(在上述情况下)包括 Tomcat/JBoss + MySQL 处理时间。它对我的情况没有帮助,因为它包括 MySQL 处理时间 - 我只想记录 JBoss 上的请求处理时间。有什么建议/想法值得赞赏吗?
使用 AccessLogValve:它可以通过在 AccessLogValve XML 构造的模式属性中设置 %D 来记录“处理请求所花费的时间,以毫秒为单位”。不太清楚这个
- 时间是否是tomcat/JBoss服务所需的时间 请求(例如,分配线程工作程序来处理它)
- 处理请求并将其发送到数据库服务器所花费的时间 (Tomcat/JBoss 服务器上的总时间)
- Tomcat/JBoss 处理请求并发送响应所花费的时间 返回到 Web 服务器/客户端
有什么想法/线索吗?
这是我想分享的经验/研究。如果有人有类似的问题/知道如何做到这一点来分享他们的经验/指针/想法,以便找到更好的解决方案,我们将不胜感激。
期待您的想法/建议
My web application architecture is: Apache 2 (as load balancer) + JBoss 3.2.3 + MySQL 5.0.19.
I want to: measure the request processing time (for every individual request) spent on the JBoss server only (i.e., excluding time spent on Web and database servers.
I've been researching about how to log request processing time on an application tier only. I found *mod_JK logging*, *Apache's mod_log_config* and Tomcat AccessLogValve as two possible methods.
Using *mod_JK logging*: my understand mod_jk logging provides request processing time for each request and calculate as time difference between time when a request leaves the Apache server and time when the corresponding response received by the Apache server. Please correct me if this not accurate/correct.
Using Apache's mod_log_config model (http://www.lifeenv.gov.sk/tomcat-docs/jk/config/apache.html): by adding "%{JK_REQUEST_DURATION}n" in the LogFormat (the JKLogFile construct) construct (see the above link). The "JK_REQUEST_DURATION" capture overall Tomcat processing time from Apache perspective.
The times (in the above cases) includes Tomcat/JBoss + MySQL processing time. It won't help in my case as it includes MySQL processing time- I want to record request processing time on JBoss only. Any suggestions/ideas are appreciated?
Using AccessLogValve: it can log "time taken to process request, in millis" by setting %D in the pattern attribute of the AccessLogValve XML construct. It is not very clear if this
- Time if this time is the time required by tomcat/JBoss to serve a
request (e.g., allocate thread worker to handle it) - Time taken to process a request and send it to the database server
(overall time on Tomcat/JBoss server) - Time taken to process a request by Tomcat/JBoss and send a response
back to a Web server/client
Any idea/clue?
This is my experience/research I want to share. It would be appreciated if anyone has similar problem/know a way to do it to share their experience/pointers/thoughts where a better solution can be found.
looking forward for your thoughts/suggestions
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
为什么要排除数据库时间?花在数据库上的时间是应用程序等待的时间,就像它等待其他资源一样,例如 lucene 索引完成、远程 http 请求完成等。
如果您确实想排除数据库访问时间,则需要检测您的数据库访问时间。带有定时器启动/停止指令的应用程序。这肯定需要进入您的应用程序内部(通过 AOP“干净地”或通过应用程序中关键点的启动/停止语句手动),并且不能简单地是来自外部世界的配置(例如 apache 模块)。
因此,当您在处理链的最开始处收到请求时(过滤器在这里效果很好),您需要启动计时器,并在每次发送查询时停止计时器。然后在查询之后重新开始。这当然不可能 100% 完成,特别是在您使用透明 ORM(例如 hibernate)的情况下。这是因为有时您可能会间接执行查询,即通过纯 Java 遍历集合或关联时。
Why do you want to exclude the database time? Time spent on the database is time your application is waiting, exactly as it could be waiting for other resources e.g lucene indexing to finish, a remote http request to complete etc.
If you really want to exclude the db access time you need to instrument your application with timer start/stop instructions. This will definitelly need to go inside your application (either "cleanly" via AOP or manually via start/stop statements in critical points in the app) and cannot simply be a configuration from the outside world (e.g an apache module).
So, you'll need to start the timer when you receive your request in the very start of the processing chain (a filter works well here) and stop every time you send a query. Then start again exactly after the query. This of course cannot be 100% complete especially in the case you use a transparent ORM such as hibernate. That's because sometimes you could be executing queries indirectly, i.e when traversing a collection or an association via plain Java.
我认为您正在寻找分析工具,例如 java VisualVM、JProfiler 或其他..
I think you are looking for profiling tools, like java visualVM, JProfiler or others ..