I have a WCF service needing to access a read-only repository of information. This repository is expensive to create which means that it needs to be created once and shared between service calls/instances of the service class. Making the class thread safe in general is not a problem as well as making the respository thread safe. I'm considering two options for sharing the respository:
Simply set "InstanceContextMode" to "Single" and "ConcurrencyMode" to "Multiple", create the single service object manually and have the single repository injected into it through the constructor.
Use "InstanceContextMode" set to "PerCall" (or "PerSession") and implement a custom service instance provider for my service. This instance provider could inject the single instance of the repository into all service class instances (constructor) as a part of the creation process.
What are the reasons for NOT using option 1 here given my situation (provided that I have submitted enough information about it)? To me it seems to be the easiest? I keep reading that "InstanceContextMode" set to "Single" is bad for performance/scalability but I fail to grasp if this is ALWAYS the case or if it depends on the service properties.
As already mentioned I realize it's possible that I haven't provided enough information about my specific case for any of you to be able to answer.
Best regards, Johan