none
WCF - client connections - scalabilty RRS feed

  • Question

  • I'm not sure how to ask this correctly as having Googled this for several days I cannot find anything useful - which usually means I'm asking the wrong question.

    The question is in regard to scaling up the use of Windows Communication Foundation and whether there are connection limits that we need to be mindful of.

    The clients that call the WCF services close the connection after each call following patterns in the Microsoft documentation (including the advice in https://docs.microsoft.com/en-us/dotnet/framework/wcf/samples/avoiding-problems-with-the-using-statement) but the client connection can be seen in Performance Monitor to remain open until Windows cleans it up after a default number of seconds (100 I believe).

    The above is based on using the System.ServiceModel.BasicHttpBinding or WSHttpBinding which do not support KeepAliveEnabled.

    If we switch the bindings to System.ServiceModel.Channels.CustomBinding and set KeepAliveEnabled to false then the connection disappears immediately after the call.

    With the first options (BasicHttpBinding and WSHttpBinding) the open connections are reused by the client (and I believe there is a limit of 2 connections imposed by Windows for one PC to one server endpoint) so the rate of increase of open/sleeping connections is limited to some extent.

    With CustomBinding there is the overhead of opening the connection every call.

    So there are pros and cons for both approaches, what I really want to know is do the "sleeping" connections that persist with BasicHttpBinding and WSHttpBinding actually matter?

    A typical customer will have a few thousand clients - so large but not massive volumes.

    I hope you can help.

    Regards Charles Waudby

    Thursday, April 5, 2018 6:12 AM

All replies

  • Hi Charles,

    >> what I really want to know is do the "sleeping" connections that persist with BasicHttpBinding and WSHttpBinding actually matter?

    Keep connection alive would save the tcp establishing time and server CPU/memory useage.

    If there are many connections from the same computer in a short time, you may consider set keep connection alive as true.

    If there are less connections, I think you could set it as false.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Friday, April 6, 2018 4:30 AM
  • Thanks for that, but main question is about the impact at the server if, for example, 2,000 clients all keep a connection open?

    Does it matter how many of the "sleeping" connections exist at any point in time?

    If each client request takes a second and each client makes a request every 2 minutes that would only equate to 15 simultaneous requests which we can handle.

    So just: do the 2,000 persisted "sleeping" connections matter?

    Regards, Charles

    Friday, April 6, 2018 8:04 AM
  • Hi,

    >> 2,000 clients all keep a connection open?

    It will spend computer resource to keep the connection alive.

    Note, setting KeepAliveEnabled as true does not mean the connection will be open all the time. When a user visits a page and keeps the page open for Connection Time-out time without any activity, the connection will be closed.

    You could configure Connection Time-out to determine How long will close the connection if there is no active.

    Best Regards,

    Tao Zhou


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, April 9, 2018 5:25 AM
  • Hi, forgive me for being impolite, but the last post tells me nothing I did not say in the original question.

    The question I asked was ". . . The question is in regard to scaling up the use of Windows Communication Foundation and whether there are connection limits that we need to be mindful of. . . ."

    So are there resource issues on the server, remember the question is about WCF.

    The following MSDN page "explains" throttling, what I cannot work out is whether the three properties Max Concurrent Calls, Instances and Sessions are relevant to the "inactive" client connections which remain open for a while if Keep Alive is true.

    https://msdn.microsoft.com/en-us/library/system.servicemodel.description.servicethrottlingbehavior.aspx

    Monday, April 9, 2018 1:20 PM
  • >>what I cannot work out is whether the three properties Max Concurrent Calls, Instances and Sessions are relevant to the "inactive" client connections which remain open for a while if Keep Alive is true.

    No, these properties are not related with "inactive" connections.

    >>whether there are connection limits that we need to be mindful of

    There are no connection limits. But you need to pay attention to timeout. When there are large mumber connections, the request will be handled in order, and you need to increase the timeout to make request will be processed before timeout.


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, April 10, 2018 4:39 AM