制作多核优化的 ASP.NET MVC 应用程序有哪些有用的技巧?
我在 Web 上看到很多应用于桌面应用程序的多核信息 - 但我很感兴趣:对于 ASP.NET MVC Web 开发人员构建充分利用多核/处理器的应用程序,哪些提示和指示有用?
I see a lot of the multi-core information on the web applied to desktop applications - but I am interested: what tips and pointers would be useful for ASP.NET MVC web developers building applications that make the most of multiple cores/processors?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将其留给网络服务器,
除非它进行某种处理器繁重的处理,否则我不会在网络应用程序中弄乱它。确保您的应用程序性能良好,并将处理器利用率留给 Web 服务器,以便通过系统中的所有内核来处理请求。
Leave it to the web server
I wouldn't mess with it in a web application unless it does some sort of processor heavy processing. Make sure your application performs well and leave processor(s) utilization to the web server to serve requests with all cores in the system.
如果每个请求有多个长时间运行的进程,您可以将它们并行化。但通常来说,编码工作和可能出现的错误是不值得的。
在实践中,只需让每个请求变得精简,然后您就可以一次处理更多请求。
If you have multiple long running processes per request, you could parallelize them. But generally it's not worth the coding effort and bugs that could show up.
In practice, just make each request lean, and then you can handle more requests at one time.
我认为 Web 应用程序从多核/多线程中获得的价值不如桌面应用程序那么多,因为最终每个 HTTP 请求都是同步的(AJAX 除外,但每个 AJAX 请求仍然是 HTTP 请求)。当然,具有多核的服务器是一件好事,并且可能可以更快地处理请求,但我认为(一般来说)您可以使用最终呈现 HTML 文档的多线程应用程序做很多事情。
I don't think a web app gets as much value from multi-core/multi-threading as a desktop app, because ultimately each HTTP request is synchronous (except for AJAX, but each AJAX request is still an HTTP request). Certainly a server with multi-core is a good thing, and can probably handle requests faster, but I don't think there's much (in general) you can do with a multi-threading app that ultimately renders an HTML document.