WCF service starts up takes 10 seconds with a big service contract having 1000 methods

StackOverflow https://stackoverflow.com/questions/11048605

  •  14-06-2021
  •  | 
  •  

문제

I'm using a named-pipe WCF service, which has about 1000 methods (yes, I know it's not a good practice, but it's life...).

The problem I got is that when starting up the WCF service, it costs about 10 seconds on constructor of ServiceHost class. By tracking into it, I found the time is spent on preparing service description (InitializeDescription method of ServiceHostBase class). I guess it's because there are too many methods defined in this service contract.

Anyone can help to answer how can I speed up the start up time of this big service contract?

I know it's not a good practice to define so many methods in one service contract. But I can't change the service contract (such as divide it to several smaller ones). You know, this is the real life...

Thanks.

도움이 되었습니까?

해결책

Refactoring this endpoint, while non-trivial, is probably fairly easy to do if you manage the process properly:

  1. Pick a single logical business case which your endpoint currently supports.
  2. Create a list of all the operations needed to fulfil this single logical business operation.
  3. Create a new endpoint for just those operations, keeping the same operation signatures.
  4. Re-point any existing consumers who want to fulfil this business case to the new endpoint.
  5. Repeat process until you have covered all business cases.

Apologies this does not address original question directly and appreciate re-working on this scale may be outside the scope of your current development.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top