I'm finding that when I first start up my application the first client dataportal usage PER TYPE, is very slow.
So, for example, the first Fetch of MyObject takes around 800ms, whereas every subsequent MyObject takes around 250ms (the server is in a different location). If I then Fetch MyOtherObject (without restarting the application), this first usage is slow, but subsequent usages are fine.
The server is running at all times using a SelfHosted server (not IIS) so should be fully up and running and with no startup delays, so I don't believe that the server-side is affecting things.
I've had a look around at the usual suspects for first WCF usage being slow, but neither seems to make a difference:
- proxy detection (I don't have a proxy and have tried setting the relevant config file things to disable)
- serialization (I have tried forcing serialization of MyObject manually before first using the DataPortal)
I am not specifying a serializer, so I think this means that it will be using BinaryFormatter. I have my DataPortal configured to use NetTcp with transport level security.
The thing is, if this was slow for the first usage for ALL objects (i.e. the first usage of the first type is slow, but aftewards everything is fine), I would assume this is a WCF thing, but because the first usage of every type is slow, it makes me think this has something to do with CSLA and the way it does things.
This is also the same in a Release build after ngen-ing the binaries.
Does anyone have any other ideas for what could be causing this? Does anyone else see the same issue?
Could it be to do with the fact that the WCF service is based upon reflection (dynamic typing) and how the serialization handles this?