有哪些方法可以找到 Web 应用程序中的瓶颈?

2021-12-28 00:00:00 performance web-applications php asp.net

如何对网络应用程序的性能进行基准测试?

How do I benchmark the performance of my web applications?

有没有办法找出网络应用程序中的瓶颈?

Is there a way to find out the bottlenecks in a web application?

我不是在询问任何前端调整,如图像、CSS 等.我想知道的是如何分析应用程序的后端,以便我知道要修改哪些方法/查询以提高性能.

I am not asking about any front end tweaks like images, css etc. What I want to know is how to profile the back end of the application so that I will know which methods/queries to modify to increase the performance.

推荐答案

关于应用服务器上的瓶颈,您可以使用 分析工具,用于查看代码的每个部分花费了多少时间、使用了多少内存等.对于 PHP,webgrind 似乎是一种流行的基于 GUI 的分析方式.像 dotTrace 之类的东西会对 ASP.NET 应用程序做同样的事情.请注意,当涉及到数据库时,像这样的分析工具只会显示哪些数据库查询很慢——而不是为什么它们很慢.为此,您需要查看特定于数据库的分析...

Regarding bottlenecks on the application server, you can use a profiling tool to see how much time is spent in each part of your code, how much memory is used, etc. For PHP, webgrind seems to be a popular, GUI-based way of profiling. Something like dotTrace would do the same thing for an ASP.NET app. Note that when it comes to databases, profiling tools like this will only show you which database queries are slow--not why they are slow. For that, you'd need to look into database-specific profiling...

Web 应用程序瓶颈的另一个方面是浏览器下载所有内容(CSS 和 JavaScript 导入、图像等)并呈现页面实际需要多长时间.有几家公司,例如 Keynote,他们的机器人会从世界各地访问您的网站,分析性能,并向您提供有关更改的建议,以使您的应用输出到浏览器并尽快呈现(例如,使用 gzip 压缩并将您的 JavaScript 放在页面的末尾而不是头部"等).当然,您也可以在更小规模的情况下自行完成此操作.例如,像 Jiffy 和 YSlow 将完成这项工作.

Another aspect of web app bottlenecks is how much time it actually takes a browser to downlad everything (CSS and JavaScript imports, images, etc.) and render the page. There are several companies like Keynote who have bots that will hit your site from all around the world, analyze the performance, and give you recommendations about changes you can make to get the output of your app to the browser and rendered as quickly as possible (e.g., "use gzip compression and put your JavaScript at the end of the page instead of the head", etc.). You can also do this yourslelf on a much smaller scale, of course. For example, Firefox plug-ins like Jiffy and YSlow will do the job.

相关文章