【发布时间】:2012-12-02 20:43:38
【问题描述】:
我开发了一个 Windows 服务,它可以按计划备份我的文件和文件夹。它执行以下任务:
1 - 读取文件夹和文件列表
2 - 压缩它们并将它们放在临时目录中(将大文件分成 50MB 块)
3 - 将临时文件夹的内容上传到 FTP
4 - 删除临时文件夹
现在临时文件夹的大小可能在 3GB 左右,服务每天运行两次。现在我的服务器随机重启(不是在服务创建或上传数据期间),我开始认为这可能是导致我的服务器重启的 I/O 问题。
在 .NET 中优化我的服务器的最佳方法是什么?我可以将 PriorityClass 设置为BelowNormal,但我认为这不会有帮助。我的 onStart 看起来像这样......
Protected Overrides Sub OnStart(ByVal args() As String)
' Add code here to start your service. This method should set things
' in motion so your service can do its work.
Try
Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal
Dim s As New BackupLibraryV2.main
Catch ex As Exception
BackupLibraryV2.util.LogEntry("", ex.Message, DateTime.Now, DateTime.Now)
End Try
End Sub
(我应该在新线程中启动服务吗???)
是否有任何其他建议我可以尝试优化我的服务器以减少 CPU 密集度?
这是重启日志:
crash dump file: C:\Windows\Minidump\120212-14227-01.dmp
This was probably caused by the following module: ntoskrnl.exe (nt+0x7EFC0)
Bugcheck code: 0x3B (0xC0000005, 0xFFFFF800019A7382, 0xFFFFF88008DFA9E0, 0x0)
Error: SYSTEM_SERVICE_EXCEPTION
file path: C:\Windows\system32\ntoskrnl.exe
product: Microsoft® Windows® Operating System
company: Microsoft Corporation
description: NT Kernel & System
Bug check description: This indicates that an exception happened while executing a routine that transitions from non-privileged code to privileged code.
This appears to be a typical software driver bug and is not likely to be caused by a hardware problem.
The crash took place in the Windows kernel. Possibly this problem is caused by another driver that cannot be identified at this time.
【问题讨论】:
-
听起来不像是 Windows 服务的用户模式错误,因为它不太可能上下文切换到内核模式。
-
所以肯尼,你认为它是别的什么吗?我担心的原因是我几天前将它部署到服务器,今天服务器重新启动时出现意外错误。
-
是的,这是我的猜测。虽然你的应用程序会给失败的 IO 子系统增加压力。
-
您是否尝试过让正在运行您的服务的服务器停止以查看错误是否仍然出现?
-
查看应用程序日志部分的事件日志。它应该有一个包含堆栈跟踪的服务的错误条目。
标签: .net vb.net windows-services