Last post Apr 15, 2009 11:09 AM by vangeloni
Apr 15, 2009 10:43 AM|vangeloni|LINK
I am working on testing the performance of WCF service and the entityFramework.
The test scenario is the following:
I have an EntityModel, with the following entity Class: Customer mapped to the main table Customer on test db (sqlServer 2008)
I have implemented an WCF service with two methods:
getAllCustomers: returns a list of
CustomerKey, List<CustomerKey>. CustomerKey is a data contract.
getCustomerDetail(CustomerKey): returns the EntityObject Customer.
My first test is the following:
On client side I have invoked the wcf method getAllCustomers and after for
each CustomerKey in the returned list I have
invoked the wcf method
On server side I have used a new Entity Framework context for each wcf calls:
With using(MyDbEntities db= new MyDbEntities() ), so it closes the connection each time.
The total time in this case is T1 (in my example for 128 Customer was 5 seconds)
My second test is the following:
On client side I invoked all the same ( the method getAllCustomers and after for
each CustomerKey in the returned list I invoke the wcf method
On server side I have cached the Entity Framework context in order to get the object from the context instead to access to the database and maintain the connection opened at least that was my intention.
The total time in this case is T1*9,
I do not understand this performance issue. I have thought that when I have sent the entityObject object to the client (by WCF) it serialize the object so it could cause problem to the context in order to manage the attached objects.
Could you have any hints, suggestions?
Anyway could you tell me the correct way in order to cache the entityFramework context?
Thanks very much,
entity data framework
Apr 15, 2009 10:56 AM|shados|LINK
In the context of a web application (or a WCF hosted under IIS), opening and closing database connections is a near zero time operation: the connections are actually, under the hood, always kept open and alive, and opening and closing connections doesn't
actually happen. The system is just telling you its doing it, but it isn't. So no bottlenecks there. Don't keep the context in session, that may hurt more than help.
5 seconds to pull out 125 customers through WCF is insane though. Its kind of normal for the first hit, as the app domain has to be loaded, but subsequently it should be almost instant. Is the service remote?
Apr 15, 2009 11:09 AM|vangeloni|LINK
Thanks for your answer.
Yes the service is remote.
I know the time to open a connection, my target is to have a cache on server side, and anyway I do not understand the big difference on performnace side.