WCF Data Services: Call to SaveChanges() causes 100% CPU
I am developing a WCF Data Service over an Entity Framework 4.0 data model, but there's no way we can go to Production under the current circumstances.
My client application is adding and modifying a lot of objects, around 100,000. Then it calls the service's SaveChanges method to persist all changes in a single action. The WCF Data Service is hosted in an NServiceBus host process, although I don't know if that contributes to the issue.
This works, but it takes more than an hour on a 1-CPU, 4GB RAM, Win2008 x64 virtual machine. More importantly, CPU utilization goes up to 100%. RAM consumption fluctuates between 75% and 85%. T开发者_开发百科his is in a development environment virtual machine, so the SQL Server 2005 database the service is covering is local. The WCF Data Service's host process eats up around 1.2 GB during this process.
Any ideas?? Many thanks in advance!
Do you really need to modify all objects within one transaction? If no, then I would propose to hold the data context open as shortly as possible.
- Open data context
- update the object
- save changes
- close data context
精彩评论