Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
207 views
in Technique[技术] by (71.8m points)

c# - Web API Service - How to make the requests at the server to be executed concurrently

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

Are all the web requests executed in parallel and handled asynchronously?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...