Diagnostic app slow down and memory consumption (maybe WCF)? RRS feed

  • Question

  • Since about 3 weeks, we encounter a general performance and memory consumption issue in our application.

    This issue never occurs before and we don't know how to diagnostic the situation.

    This happens 'sometimes', around 1 or 2 times per week and the symptoms are the following:

    • All access to the application are slow
    • The memory used by the server part is significantly growing
    • But if we ask all users to disconnect/shutdown the client part, all is ok again after few (around 10) minutes and users can work again as if nothing has occurred before. So this is not a memory leak.

    The technical context is the following:

    • Client/server/Mongodb architecture in .net 4.6 C#.
    • Client is a WPF app
    • Server is a self hosted WCF services running as a Windows Service
    • WCF uses net tcp bindings
    • MongoDB 3.6 using 2.7 C# driver

    As the problem is really general (all services are impacted and all services are accessing to the db), we suspect either WCF or the MongoDB driver to be the cause.

    Additional symptoms:

    • The CPU used on server part is normal
    • The DB does not trace anything particular

    About WCF:

    All client calls are encapsulated in a proxy which ensures that CreateChannel/channel.Close/channel.Abort scheme is always used.

    The bindings are:

    <binding name="tcp" maxReceivedMessageSize="800000000" maxBufferSize="800000000" openTimeout="00:00:10" receiveTimeout="00:10:00" sendTimeout="00:10:00" >
      <security mode="None" />

    Behavior (there is around 100/120 client users on the concerned site):

    <behavior name="defaultServiceBehavior">
      <serviceThrottling maxConcurrentCalls="500" maxConcurrentSessions="500" />

    Implementation for duplex:

    [ServiceBehavior( InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single )]

    For single calls:

    [ServiceBehavior( InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Multiple )]

    About MongoDB:

    I've few to say because I've not found anything similar concerning the driver or the DB.

    From the server app, we use this option in the connection string: maxPoolSize=500 (and serverStatus indicates we only use 20).

    We have a replicaset and an arbiter hosted in separated servers.

    OpLog is about 200+ equivalent days in our context.

    Log indicates some but very few long running accesses (around 10 per hour but for less than 5 seconds total).

    About anything else

    Our customer indicates there is no firewall or antivirus that could perturb anything.

    Concretely my question is about finding help or advices from people that has encountered such issues or who could indicate a good approach to setup tools that could lead to a concrete diagnostic.


    Monday, June 10, 2019 6:30 AM

All replies

  • Hi ChristianHubert,

    I have no practical experience related to your scenario. As far as I know, Persession mode can maintain a logical session between a client and a specific service instance. But it is so expensive that each client gets a new instance of a proprietary service when it creates a new proxy. 
    Throughout the session, the service instance retains memory space to maintain the session state and establish the context state between multiple messages. 
    Therefore, it is more resource-consuming for the server to use PerSession service as the instance mode of the service. 

    [ServiceBehavior( InstanceContextMode = InstanceContextMode.PerSession, ConcurrencyMode = ConcurrencyMode.Single )]

    For your configuration, I don't think it's necessary to use PerSession mode. PerCall services are fine. In PerCall communication, the service instance is automatically released after each service call. 
    Duplex communication also does not require session mode to be turned on. The Nettcpbinding natively supports duplex communication

    Best Regards


    Tuesday, June 11, 2019 6:48 AM