项目绩效评估和查找薄弱环节
我正在从事 J2EE Web 项目,其中有很多 Java、SQL 脚本、JS、AJAX 内容。项目已经过去5年了,仍然运行良好。
我分配了该项目的性能评估工作,因为可能存在一些内存使用问题、数据库获取逻辑延迟和其他类似的性能薄弱区域。我应该从哪里开始?
有哪些最佳实践可以使项目变得更好?
I'm working in J2EE web project, which has lots of Java, SQL scripts, JS, AJAX stuff. Its been 5 years for project still running fine.
I have assigned with work of performance evaluation on the project as there might be some memory usage issues, DB fetching logic delays and other similar weak performance areas. From where should I begin?
Any best practices to make project better?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
最好的办法是衡量你的瓶颈在哪里?此类工作需要像 jprofiler 等东西。
The best things is to measure where your bottle-necks are? Things like jprofiler etc. are needed for such work.
通常,当某人为系统性能改进付费时,他几乎清楚地知道他/她对什么不满意。因此,首先列出问题所在。系统“慢”这一事实并不是问题,因为“慢”总是与“快”相关(例如系统无法跟上传入流量)。
一旦你有了一个列表,就可以粗略地识别出“慢”的组件。
然后使用日志记录(确保每条消息都以毫秒粒度时间戳为前缀,如果需要,请重新配置记录器)。
检查记录的“慢”操作的内容,系统在每个组件上花费了多少时间。
一旦您粗略地识别出缓慢的组件,就增加该特定组件的日志记录详细程度,并尝试找出它出了什么问题(缓慢的数据库、糟糕的代码等)。
如果您只是需要使系统更快,您可以找出首先通过在最大负载下运行的进程上重复运行“jstack”来进行优化(有人将此方法称为“蒙特卡罗分析”)。通过比较后续的堆栈转储,您可以统计地找到应用程序花费最多时间的位置并改进相应的块。
使用 jconsole 连接到正在运行的项目并跟踪内存消耗,同时查看日志文件以找出谁分配了最多内存也很有用。
Typically when someone pays for system performance improvement he knows almost exactly what he/she is not happy with. So first compose the list of what problems are. The fact that the system is "slow" is not a problem because "slow" is always relative to something "fast" (like system cannot keep up with incoming traffic).
Once you have a list, roughly identify components being "slow".
Then work with logging (make sure each message is prefixed with millisecond-granularity timestamp, reconfigure logger if required).
Check what is logged for "slow" operation, how much time does the system spend in each component.
Once you roughly identified the slow component, increase logging verbosity for this particular component and try to figure out what is wrong with it (slow DB, poor code, etc.)
If you just need to make the system faster, you can find out the first place to optimize by repeatedly running "jstack" on the process running under maximum load (some call this method "monte carlo profiling"). By comparing subsequent stack dumps you can find where the application spends the most of its time statistically and improve corresponding block.
It is also useful to connect with jconsole to the running project and track memory consumption while looking in the log files to find out who allocates the most memory.