WCF Service and Threading

后端 未结 4 1545
庸人自扰
庸人自扰 2021-01-02 11:21

I have created a simple WCF (.NET 3.5) service which defines 10 contracts which are basically calculations on the supplied data. At the moment I expect quite few clients to

4条回答
  •  太阳男子
    2021-01-02 11:58

    By default the Instancing is PerSession. See WCF Service defaults

    However if you use a session binding that doesn't support sessions (like BasicHttpBinding) or the the channel/client does not create a session then this behaves like PerCall

    See [Binding type session support] (https://docs.microsoft.com/en-us/dotnet/framework/wcf/system-provided-bindings).

    Each WCF client object will create a Session and for each session there will be a server instance with a single thread that services all calls from that particular WCF client object synchronously.

    Multiple clients therefore would each have their own session and therefore server instance and thread by default and would not block each other. They will only affect each other on shared resources like DB, CPU etc.

    See Using sessions

    Like others suggested you should make sure the implementation is efficient BEFORE you start playing with the Instancing and Concurrency modes.

    You could also consider client side calculations if there is no real reason to make a call to the server.

提交回复
热议问题