任务管理器中的CPU时间到底是什么?
我有一些托管在 Windows 服务中的 WCF 服务。 昨天我查看任务管理器,发现我的 Windows 服务进程的 CPU 时间超过 5 小时,而大多数其他进程的 CPU 时间为 0。
这是什么意思?
我应该担心 CPU 时间超过 5 小时吗?
I have some WCF services that are hosted in a windows service. Yesterday I looked at Task Manager and noticed that the CPU time for my windows service process was over 5 hours, while the majority of all other processes were at 0.
What does that mean?
Should I be concerned that the CPU Time was 5+ hours?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
CPU 时间 指示进程自启动以来已使用多少处理时间(Windows定义方式相同,如 Microsoft Learn 中这篇针对 Windows 2000 的文章< /a>)。
它基本上是通过以下方式计算的:
例如,如果进程运行了5个小时,CPU时间为5小时,则意味着该进程已经使用了100%的CPU资源。 这可能是好事也可能是坏事,具体取决于您是否想要保持较低的资源消耗,或者想要利用系统的全部功能。
如果进程使用了 50% 的 CPU 资源并运行了 10 小时,则 CPU 时间将为 5 小时。
CPU time is an indication of how much processing time a process has used since it has started (Windows defines it the same way, as documented on Microsoft Learn in this article for Windows 2000).
It is basically calculated by:
For example, if the process has been running for 5 hours and the CPU time is 5 hours, then that means that the process has been utilizing 100% of the resources of the CPU. This may either be a good or bad thing depending on whether you want to keep resource consumption low, or want to utilize the entire power of the system.
If the process was using 50% of the CPU's resource and running for 10 hours, then the CPU time will be 5 hours.
CPU 时间反映了程序花费在 CPU 中执行指令的时间与等待 IO 或其他资源的时间。 您应该担心 5 个小时以上吗?
我想不会,需要考虑的一些事情是:
此进程运行了多长时间?
您对可能会窃取 CPU 的机器上的进程或其他进程的性能有任何问题吗?
你们还有哪些其他流程? 这些活动进程是您期望使用 CPU 的吗? 作为 80 个进程的参考,我有大约 20 个进程使用了超过 1 秒的 CPU 时间。
编辑
WCF 服务可能会从其他服务中窃取 CPU,您需要监视它们以确保它们的性能符合您的预期。 您还可以根据总 CPU 使用情况了解情况。 例如,如果您只看到 CPU 使用了 25%,那么您的其他服务应该不会受到影响; 但是,如果您的跑步率超过 75%,那么它们可能会受到影响。
当涉及到监控时,请确保随着时间的推移进行监控,以便您可以了解性能趋势,并且它将帮助您隔离问题。 例如,您的服务运行良好,但部署后它慢慢开始占用越来越多的 CPU(假设每周 10%)。 除非您对 CPU 使用情况进行趋势分析,否则您可能有一天醒来会发现您的服务运行缓慢,这可能是在部署几周后。
CPU Time is a reflection of how much time your program spends executing instructions in the CPU vs waiting for IO or other resources. Should you be concerned with it being 5+ hours?
I would guess not, some things to consider are:
How long has this process been running?
Do you have any issues with the performance of the process or other processes on the box that this might be stealing CPU from?
What other processes do you have? Are these active processes that you'd expect to use the CPU? For reference of the 80 processes I have about 20 have over 1 second of CPU time used.
Edit
It is possible that the WCF service is stealing CPU from the other services, you need to monitor them making sure their performance is what you expect. You can also get a sense based on Total CPU usage. If you for example you only see 25% of your CPU used, then your other services should not be affected; however, if your running above 75% then they might be affected.
When it comes to monitoring be sure to monitor over time so you can see how the performance trends, and it will help you isolate problems. For example you service is running fine but then after a deploy it slowly starts to take more and more CPU (Assume 10% a week). Unless your trending your CPU usage you might one day wake up and see your service running slowly which could be weeks after a deploy.
如果您担心进程使用了多少 CPU 时间,则应该使用 perfmon 长时间跟踪进程的 CPU 使用情况以确定是否存在问题。
If you are concerned about how much CPU time your process is using, you should use perfmon to track your processes' CPU usage over an extended period of time to determine if you have a problem.
任务管理器中的CPU时间到底是什么?
答案很简单:
进程自启动以来使用的总处理器时间(以秒为单位)。
What exactly is CPU Time in task manager?
Answer is simple :
The total processor time, in seconds, used by the process since it was started.