什么可以使 SQL Server DB 表现出循环 CPU 使用行为?
我有一个正在处理来自 MSMQ 队列的消息的系统(使用多个进程来进行处理)。
每个消息处理意味着读取一些行,并进行 3 次更新和 1 次插入。我用这个系统每秒处理大约 60 条消息。
令我困惑的是,无论出于何种原因,当队列中消息堆积时,系统正在以最快的速度处理消息时,CPU 使用率会出现一个峰值为 95%-100%,谷值为 95%-100% 的周期。 50%-45%。即使我添加更多进程来进行处理,这种行为仍然存在。
当工作负载意味着行插入和更新(我正在考虑缓存刷新等)时,是否期望 SQL Server 显示该行为?也许它与主机有关(这是在 Hyper-V 上运行,而不是在真实硬件上运行)?
以下是 perfmon 运行的链接: http://dl.dropbox.com/u/2200654 /sql_perf_000001.rar
I have a system that is processing messages from an MSMQ queue (using multiple processes to do the processing).
Each message processing implies reading some rows, and making 3 updates and 1 insert. I'm processing around 60 messages per sec with this system.
What is puzzling me is that when for whatever reason, the queue has a buildup of messages, and the system is working as fast as it can to process messages, the CPU usage exhibits a cycle with peaks of 95%-100% and valleys of 50%-45%. This behavior holds even when I add more processes to do the processing.
Is it expected of SQL Server to show that behavior when the workload implies row insertion and updates (I'm thinking cache flushing, etc.)? Maybe it's got something to do with the host (this is running on Hyper-V, instead of on real hardware)?
Here's a link to a perfmon run: http://dl.dropbox.com/u/2200654/sql_perf_000001.rar
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这是如何针对默认 SQL Server 实例以 10 秒收集间隔启动一些相关计数器的 logman 计数器跟踪的示例:
命名实例将计数器类别名称从“SQLServer:...”更改为“:...
”上传的性能计数器缺少物理磁盘计数器,因此 IO 分析不完整,但值得注意的是 CPU 使用率百分比与 SQL Server 事务/秒和批次/秒完全匹配:
请注意红线 (% CPU) 如何完全遵循绿线 (事务数/秒) 的形状以及蓝线(批次/秒)。这表明峰值完全由应用程序行为驱动。简而言之,SQL Server 的 CPU 峰值(以及 IO 写入读取(紫色线))仅仅是因为您的应用程序每 3 分钟左右就会出现请求峰值。
This is an example how to start logman counter trace for some relevant counters, with 10s collection interval, for a default SQL Server instance:
Named instances change the counter category name from "SQLServer:..." to ":..."
The uploaded performance counters are missing the Phsyical Disk counters so the IO analysis is incomplete, but one think standing out is that the % CPU usage is an exact match of the SQL Server transaction/sec and batches/sec:
Note how the red line (% CPU) follows exactly the shape of the green line (Transactions/sec) and also the blue line (Batches/sec). This indicates that the spikes are entirely driven by the application behavior. Simply said, the SQL Server spikes in CPU (and also on IO write read, the purple line) simply because your application spikes requests every 3 minutes or so.
检查其余部分 - 是否您遇到了检查点,因此处理速度减慢,直到脏页写入数据库?
Check the rest - could it be you hit acheckpoint and thus processing slows down until the dirty pages are written to the database?
我找到了这种奇怪行为的原因:缺乏记忆。当我添加“内存:页面读取/秒”计数器时,谷值与高页面错误时间一致。
感谢您的回答(现在这个问题看起来很愚蠢,我会要求更多的内存:)。
I've found the reason of the strange behavior: lack of memory. When I added the 'Memory: Page Reads/sec' counter, the valleys coincided with times of high page faulting.
Thanks for your answers (now the question seems silly, I'll ask for more memory :).