Search code examples
multithreadinghttpwebrequestbandwidth

Low bandwidth with multi-threaded httpWebRequest


I've a wcf service that call a webservice asynchronously using httpwebrequest.beginGetResponse(). My problem is that when I call it from another service using TPL (max concurrency : 300), my bandwidth downed and impossible to connect to internet. Does anyone have a good solution to limit this bad effect? I already tried to configure in the config

<connectionManagement>
    <add address="*" maxconnection="2000" />
</connectionManagement>

but this doesn't work

Thanks to your help


Solution

  • I get it... In my wcf service, I replace

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

    with

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

    Now that's work fine. Who have an explanation?