我怎么知道为什么我的JRuby rails应用要花很长时间来服务一个页面呢?

时间:2021-08-02 06:43:50

I'm using Tomcat to hold my rails application, but I found it took too long to serve a request for example:

我正在使用Tomcat来保存我的rails应用程序,但是我发现它花了太长的时间来处理一个请求,例如:

Completed 200 OK in 11141ms (Views: 204.0ms | ActiveRecord: 218.0ms)

在11141ms完成200 OK(查看:204.0ms | ActiveRecord: 218.0ms)

I'm wondering why it took about 11 seconds to complete the request. Views and ActiveRecord just took 400ms, what was rails doing in other 10 seconds?

我想知道为什么完成这个请求需要11秒。视图和ActiveRecord只用了400ms,而rails在其他10秒里做了什么呢?

1 个解决方案

#1


1  

There is no better way to debug performance problems than using a profiler. Yes, you can probably get away with logging stuff but it's painful to set up and it's not always possible, especially when problems are not in your code but someone else's. There's also BTrace but you need to know lots of internals which is time consuming and unnecessary.

没有比使用分析器更好的方法来调试性能问题了。是的,您可以不写日志,但是设置日志是很痛苦的,而且也不总是可能的,尤其是当问题不在您的代码中,而在其他人的代码中。也有BTrace,但是你需要了解很多内在的东西,这些东西既费时又没有必要。

So grab a profiler, run Tomcat and see for yourself. I prefer YourKit which costs $$$, but there's VisualVM which is free.

因此,获取一个分析器,运行Tomcat,然后自己查看。我更喜欢售价$$的YourKit,但是还有免费的VisualVM。

#1


1  

There is no better way to debug performance problems than using a profiler. Yes, you can probably get away with logging stuff but it's painful to set up and it's not always possible, especially when problems are not in your code but someone else's. There's also BTrace but you need to know lots of internals which is time consuming and unnecessary.

没有比使用分析器更好的方法来调试性能问题了。是的,您可以不写日志,但是设置日志是很痛苦的,而且也不总是可能的,尤其是当问题不在您的代码中,而在其他人的代码中。也有BTrace,但是你需要了解很多内在的东西,这些东西既费时又没有必要。

So grab a profiler, run Tomcat and see for yourself. I prefer YourKit which costs $$$, but there's VisualVM which is free.

因此,获取一个分析器,运行Tomcat,然后自己查看。我更喜欢售价$$的YourKit,但是还有免费的VisualVM。