问题描述
提供了有关为什么结构化异常处理是坏的。有没有办法让你的服务器停止服务器崩溃,同时克服了文章中提到的问题的鲁棒性?
我有一个服务器软件,运行大约400个连接用户并发。但是如果有一个崩溃所有400用户受到影响。我们添加了结构化异常处理,并享受了一段时间的结果,但最终不得不删除它,因为一些崩溃导致整个服务器挂起(这比只是崩溃和重新启动本身更糟糕)。
所以我们有这样:
- 使用SEH:400个用户中只有一个用户遇到大多数崩溃问题
- 没有SEH:如果任何用户遇到崩溃,则所有400都会受到影响。
- 但是有时SEH:服务器挂起,
- With SEH: only 1 user of the 400 get a problem for most crashes
- Without SEH: If any user gets a crash, all 400 are affected.
- But sometimes with SEH: Server hangs, all 400 are affected and future users that try to connect.
将您的程序分解为多个工作进程和一个单独的工作进程。 服务器进程。服务器进程将处理初始请求,然后将它们关闭工作进程。如果工作进程崩溃,则只会影响该工作进程的用户。不要使用SEH进行一般的异常处理 - 正如你已经发现的,它可以并且会让你大打开死锁,你仍然可以崩溃。
This article gives a good overview on why structured exception handling is bad. Is there a way to get the robustness of stopping your server from crashing, while getting past the problems mentioned in the article?
I have a server software that runs about 400 connected users concurrently. But if there is a crash all 400 users are affected. We added structured exception handling and enjoyed the results for a while, but eventually had to remove it because of some crashes causing the whole server to hang (which is worse than just having it crash and restart itself).
So we have this:
Break your program up into worker processes and a single server process. The server process will handle initial requests and then hand them off the the worker processes. If a worker process crashes, only the users on that worker are affected. Don't use SEH for general exception handling - as you have found out, it can and will leave you wide open to deadlocks, and you can still crash anyway.
这篇关于使用多线程服务器的结构化异常处理的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!