Andy
Andy

Reputation: 187

Concurrency management in WCF

i have implemented a fairly simple wcf service which handles the file transfers from my clients to the server the problem is when a client sends a file request. all of the bandwidth is allocated to that single client and others have to wait until the requested file transfer is completed. So my question is how to make the service more efficient and let the users share the bandwidth

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

I set the InstanceContextMode attribute to PerCall but that didn't do the trick

UPDATE : This Project is similar to mine http://www.codeproject.com/Articles/33825/WCF-TCP-based-File-Server

Upvotes: 2

Views: 269

Answers (3)

Gilad
Gilad

Reputation: 2886

WCF does not have proper load balancing, you will have to develop one yourself. If you are transferring files, lets assume download, you should send packets of data rather than the complete file at once. When doing this, add 'delays/sleeps' to the process to limit the amount of bytes the server sends on each time window, this will make room for other requests.

Upvotes: 5

tom redfern
tom redfern

Reputation: 31760

It's questionable that it's desirable to serve up files through a WCF endpoint. The reasons against doing this are pretty much exactly the problems you have been having. It works for a few clients at a time - but scaling out requires hosting new instances of the service behind a load balancer.

It would be worth considering hosting your files with some kind of storage service and have your WCF service simply return a link or handle to the file. Then the file can be retrieved offline. Microsoft have created Azure Blob Storage for this exact purpose.

Appreciate this does not address your original question, and understand the scope of your requirement may not accommodate a large reworking.

Upvotes: 4

Petar Vučetin
Petar Vučetin

Reputation: 3615

Another option is to use chunking channel if you are transferring large files. Examples: MSDN, codeplex.

Although I agree with @hugh position.

Upvotes: 1

Related Questions