简体   繁体   English

生产中的性能问题

[英]Performance issue in production

Hi I am working on a web based java tool.嗨,我正在研究基于 web 的 java 工具。 We have two instances of our tool deployed in 2 separate servers – one in production (used concurrently by many customers) and one in dev environment rarely used by me.我们有两个我们的工具实例部署在 2 个单独的服务器中——一个在生产环境中(许多客户同时使用),一个在我很少使用的开发环境中。 Both the instances, dev and production, are deployed in exactly equivalent servers with same hardware specifications, have the exact code, heap size size, application server, version etc.开发和生产实例都部署在具有相同硬件规格的完全相同的服务器中,具有准确的代码、堆大小、应用程序服务器、版本等。

But I am observing much slowness in the production instance, compared to dev instance even at odd hours in the night when customer usage is zero (We have tools to monitor customer usage in production).但是我观察到生产实例的速度慢得多,与开发实例相比,即使在客户使用量为零的夜间奇数小时(我们有工具来监控生产中的客户使用情况)。 This is surprising because all factors are identical.这是令人惊讶的,因为所有因素都是相同的。 I am assuming that since the production instance is highly used, the heap there is almost full and fragmented while the heap in dev is relatively free and unfragmented.我假设由于生产实例的使用率很高,因此那里的堆几乎已满且碎片化,而 dev 中的堆相对空闲且未碎片化。 This is why the dev instance is much faster, even though everything is identical.这就是为什么开发实例要快得多的原因,即使一切都是一样的。 Is this a reasonable assumption since a fragmented almost full heap will spend more time in object creation and thus degrade performance?这是一个合理的假设,因为碎片化的几乎满堆将花费更多时间创建 object 并因此降低性能?

Most GC perform copies and compaction which avoid any fragmentation.大多数 GC 执行避免任何碎片的复制和压缩。 Only Concurrent Mark Sweep can get some fragmentation, however this shouldn't be a problem in most cases.只有并发标记扫描可以得到一些碎片,但是在大多数情况下这应该不是问题。

Rather than guessing what your problem could be I suggest you measure what the system is doing.我建议您衡量系统正在做什么,而不是猜测您的问题可能是什么。 Ideally you want to profile your production system.理想情况下,您想要分析您的生产系统。 eg during the night or under low load.例如在夜间或低负载下。 eg VisualVM (free) or YourKit (better, not free,) If this is not an option.例如 VisualVM(免费)或 YourKit(更好,不是免费),如果这不是一个选项。 you can monitor its memory usage and how much time it spends GCing.您可以监控其 memory 的使用情况以及它花费了多少时间进行 GC。 eg with jstat例如使用jstat

However, if you haven't profiled your application, I suggest you do so because there are likely to be some obvious and simple things you can do to improve performance, even if you run it on development with a reasonably realistic work load.但是,如果您还没有分析您的应用程序,我建议您这样做,因为您可能可以做一些明显而简单的事情来提高性能,即使您在开发中以相当现实的工作负载运行它也是如此。

Are you sure you servers is not being scanned by web scanners?您确定您的服务器没有被 web 扫描仪扫描吗? (They tend not to sleep and can be active any time of the day/night) (他们往往不睡觉,可以在白天/晚上的任何时间活动)

Why was it assumed that the heap is fragmented?为什么假设堆是碎片化的? You can use VisualGc, a plugin for visual VM to analyze GC stats in real time.您可以使用 VisualGc,一个用于可视 VM 的插件来实时分析 GC 统计信息。 You can take one of the production servers out of traffic and profile it too.您可以将其中一台生产服务器从流量中取出并对其进行分析。

http://java.sun.com/performance/jvmstat/visualgc.html http://java.sun.com/performance/jvmstat/visualgc.html

There are many factors to consider in your analysis.在您的分析中需要考虑许多因素。 Latency, Network / Disk IO, database records and their size + indexes, etc to name a few.延迟、网络/磁盘 IO、数据库记录及其大小 + 索引等等等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM