views:

290

answers:

1

I have a web application uses a proxy to invoke an operation on a WCF Service that returns data from an AS400, like the different Sales Regions associated with our companies, the different stores we have out in the field, etc. These Sales regions and Stores don't change often, stores are only added maybe twice a year and regions have been the same for a couple of years.

I guess my confusion lies with InstanceContextMode. I'm just returning a list of "Regions" and "Stores" when the proxy client invokes GetRegions() or GetStoresForRegion(int regionNumber)

If I set the InstanceContextMode to single and have the regions and stores initialized and populated to prior to any service operation call, will this help in any way? Basically right now, its doing a DB lookup on every call, and I don't think there is a need.

So user logs on to web app -> web app page -> has to load drop down of regions -> web developer invokes proxy to get regions... but this is happening when every single user uses the web app so basically every single time a user access the web app, the proxy makes a call to the DB, I believe this is folly and an error in the way I set up the service operation or have I completely misunderstood something?

Update - Service is IIS hosted, so this whole question might be moot

+1  A: 

The basic best practice recommendation would be to use per-call, single instance services. That's the easiest to create, no concurrency nightmares etc.

BUT: of course each time you call the service, a service instance is created and the database backend is queried.

If ever possible, try to stick with this. Try to put the caching logic into the database - if you have enough RAM, most of your frequently requested data will stay in memory.

Going to a instanceContextMode = multiple in your WCF services causes all sorts of concurrency problems to show up that you need to be extremely careful with. Try to avoid this whenever possible.

Try per-call, single-instance first and ONLY optimize if you REALLY have to!

Marc

marc_s