如何为网站执行分析? [英] how to perform profiling for a website?

查看:109
本文介绍了如何为网站执行分析?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前有一个django网站,这很慢,所以我想了解发生了什么。如何区分以下内容:




  • 网络效果

  • 托管我正在使用服务器端执行(python code)和sql访问的javascript

  • 效果


  • 我没有考虑任何其他的影响,因为我今天晚上发生了巨大的头痛。



当然,对于他们中的一些,我可以使用firebug,但一些效果是相关的(例如,由于网络访问缓慢,JavaScript可能会慢)



谢谢

解决方案

客户端:




  • 检查与firebug如果/哪个页面组件需要很长时间才能加载,浏览器在加载完成后需要多长时间才能呈现页面。如果一切都很快,但渲染需要时间,那么可能你的html / css / js是问题,否则就是服务器端。



服务器端(我假设你坐在一些类似unix的服务器上):




  • 使用apache bench(ab,apache webserver包的一部分)或 httperf ,服务器应该能够至少应答100个请求第二(当然这在很大程度上取决于您的测试内容,网络服务器类型,硬件和其他内容的大小,所以不要认真对待100)。如果看起来不错,


  • 测试django与 ab httperf 在一个静态视图(一个不使用数据库对象),如果这慢慢的一个提示,你需要更多的CPU功率。使用 top 检查服务器上的cpu利用率。如果是这样,问题可能是网络服务器执行python代码


  • 如果服务半静态内容可以,您的问题可能是数据库或IO绑定。数据库问题是一个广泛的领域,这里是一些一般建议:




    • 检查i / o吞吐量与 iostat 。如果你看到很多的写作,那么你得到一个更好的光盘子系统,更快的RAID,SSD硬盘驱动器或优化你的应用程序写少。

    • 如果它的大量读取,主机可能没有足够的ram专用于文件系统缓冲区,或者您的数据库查询可能无法优化

    • 如果i / o看起来正常,那么数据库可能不适合您的工作负载正确配置记录缓慢的查询和监视数据库活动,锁等可能会给您一些想法




如果你让我们知道你使用什么硬件/软件,我可能会提供更详细的建议。



编辑/ PS:忘了一件事:当然你的应用可能有糟糕的设计,做了很多不必要/无效的东西...


I currently have a django site, and it's kind of slow, so I want to understand what's going on. How can I profile it so to differentiate between:

  • effect of the network
  • effect of the hosting I'm using
  • effect of the javascript
  • effect of the server side execution (python code) and sql access.
  • any other effect I am not considering due to the massive headache I happen to have tonight.

Of course, for some of them I can use firebug, but some effects are correlated (e.g. javascript could appear slow because it's doing slow network access)

Thanks

解决方案

client side:

  • check with firebug if/which page components take long to load, and how long the browser needs to render the page after loading is completed. If everything is fast but rendering takes its time, then probably your html/css/js is the problem, otherwise it's server side.

server side (i assume you sit on some unix-alike server):

  • check the web server with a small static content (a small gif or a little html page), using apache bench (ab, part of the apache webserver package) or httperf, the server should be able to answerat least 100 requests per second (of course this depends heavily on the size of your test content, webserver type, hardware and other stuff, so dont take that 100 to seriously). if that looks good,

  • test django with ab or httperf on a "static view" (one that doesnt use a database object), if thats slow it's a hint that you need more cpu power. check cpu utilization on the server with top. if thats ok, the problem might be in the way the web server executes the python code

  • if serving semi-static content is ok, your problem might be the database or IO-bound. Database problems are a wide field, here is some general advice:

    • check i/o throughput with iostat. if you see lot's of writes then you have get a better disc subsystem, faster raid, SSD hard drives .. or optimize your application to write less.
    • if its lots of reads, the host might not have enough ram dedicated as file system buffer, or your database queries might not be optimized
    • if i/o looks ok, then the database might be not be suited for your workload or not correctly configured. logging slow queries and monitoring database activity, locks etc might give you some idea

if you let us know what hardware/software you use i might be able to give more detailed advice

edit/PS: forgot one thing: of course your app might have a bad design and does lots of unnecessary/inefficient things ...

这篇关于如何为网站执行分析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆