网络API服务 - 如何使在服务器的请求被同时执行 [英] Web API Service - How to make the requests at the server to be executed concurrently

查看:119
本文介绍了网络API服务 - 如何使在服务器的请求被同时执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的WebAPI休息服务控制器,由IIS 7.5托管,
当我从这篇文章明白了:

I am using a WebApi rest service controller, hosted by IIS 7.5, as i understood from this post:

<一个href=\"http://stackoverflow.com/questions/23845639/are-all-the-web-requests-executed-in-parallel-and-handled-asynchronously\">Are所有的并行执行和异步处理Web请求?

A 的WebAPI 服务,默认情况下,并行执行所有传入的请求,但只有如果在当前多个请求(在一定的时间)来自不同的会话。
也就是说,如果一个客户端会发送一些的同时请求服务器,它们都将被执行的依序并不会同时执行

A webApi service, by default, executes all its incoming requests in parallel, but only if the current multiple requests (at a certain time) came from different sessions. That is to say, if single client will send some simultaneously requests to server, all of them will be executed sequentially and won't be executed concurrently.

这行为是一个真正的问题作为我们,因为在某些情况下,我们的客户发送一堆不同客户的听众,请求异步(通过浏览器),和所有的人实际上是<强>排队,而不是被是在服务器同时执行。因此,在某些情况下,我们遇到的严重的性能问题这是在客户端的网页确实引人注目。

This behavior is a real problem for us, because in some cases, our client sends bunch of requests from different client's listeners, asynchronously (by browser), and all of them will actually be queued instead of being executed concurrently at the server. Therefore, in some cases, we experiencing a serious performance issues which are really noticeable at the client's web page.

我们如何才能解决这个问题呢?
我明白,我们也许可以停用会话状态但是这是不正常的事情。

How can we solve this problem? I understand we can maybe disable session state but that isn't a normal thing to do.

推荐答案

其实,禁用会话状态是的正常的用于Web API的解决方案。如果你需要它的一些/所有的通话,你可以调用的 HttpContext.SetSessionStateBehavior (例如,从的Application_BeginRequest )。多个只读会话状态请求可以同时运行。

Actually, disabling session state is the normal solution for web APIs. If you need it for some/all of your calls, you can call HttpContext.SetSessionStateBehavior (e.g., from Application_BeginRequest). Multiple read-only session state requests can run concurrently.

这篇关于网络API服务 - 如何使在服务器的请求被同时执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆