WCF service starts up takes 10 seconds with a big service contract having 1000 methods
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...
Refactoring this endpoint, while non-trivial, is probably fairly easy to do if you manage the process properly:
- Pick a single logical business case which your endpoint currently supports.
- Create a list of all the operations needed to fulfil this single logical business operation.
- Create a new endpoint for just those operations, keeping the same operation signatures.
- Re-point any existing consumers who want to fulfil this business case to the new endpoint.
- 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.