实体框架与 Sql Azure 通过 net tcp 性能缓慢
嘿伙计们,
所以我这里有一个非常大的性能问题。我有一个 WPF 应用程序,它连接到在辅助角色内运行的服务。该服务使用全双工的 net tcp 绑定。数据访问层全部位于我在服务中引用的库中。因此,当我的服务想要获取数据时,它会使用该库中的方法。该库使用映射到 Sql Azure 数据库的 EF 4.1。
我面临的问题是,像从数据库获取用户这样的查询需要 4 秒以上的时间。我还有一个 http 服务(由 Silverlight 应用程序使用),它使用相同的数据访问库,相同的查询需要 115 毫秒,这是正常的。
当我使用 net tcp 服务时,实体框架是否存在问题?我真的不知道问题出在哪里,因为通过 http 服务,所有查询都表现正常。
Hy guys,
So i have a really big performance issue here. I have a WPF application which connects to a service which runs inside a Worker Role. The service uses net tcp binding with full duplex. The data access layer is all in a library which i am referencing in my service. So when my service want's to get data it uses the methods in that library. That library uses EF 4.1 which is mapped to an Sql Azure database.
The problem i am facing is that a query like getting a user from a database, takes somewhere above 4 seconds. I have also a http service(used by a Silverlight app) which uses the same dataaccess library, the same query over there takes 115ms, which is normal.
Is there a problem with the Entity Framework when i am using a net tcp service? I really don't know where the issue is, because over a http service all the queries behave normaly.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您是否有可能在实体中使用延迟加载而不是预加载?通过 Internet 进行延迟加载的速度要慢得多,因为它会导致与 SQL Azure 的往返次数增多,这在本例中将成为瓶颈。预加载只需一次往返即可立即获取所有数据。
参考:http://msdn.microsoft.com/en-us/library/bb896272 .aspx
Is it possible you are using Lazy Loading instead of Eager loading with your entity? Lazy Loading over the Internet is much slower since it results in many more roundtrips to SQL Azure, which would be the bottle neck in this case. Eager Loading will simply get all of the data at once with a single round trip.
Reference: http://msdn.microsoft.com/en-us/library/bb896272.aspx