最有效地获取SQL连接使用ASP.NET和Web服务时 [英] Obtaining SQL connection most efficiently when using ASP.NET and web services

查看:127
本文介绍了最有效地获取SQL连接使用ASP.NET和Web服务时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用Web服务(我们使用专门ASMX和WCF)与ASP.NET,什么是建立SQL连接的最佳方式?现在,我建立每个Web服务调用一个新的连接,但我不相信这将是太有效率的时候会有成千上万的连接的用户。有关此主题的任何见解将是非常美联社preciated。

When using web services (we're specifically using asmx and WCF) with ASP.NET, what is the best way to establish a SQL connection? Right now, I'm establishing a new connection for each web service call, but I'm not convinced this will be too efficient when there will be thousands of users connecting. Any insight on this topic would be much appreciated.

推荐答案

你在做什么是相当标准。

What you are doing is fairly standard.

假设你正在使用的相同的连接字符串时,连接将从连接池,这是最有效的方式来获得的连接已经到来。

Assuming you are using the same connection string, the connections will be coming from the connection pool, which is the most efficient way to get connections already.

只有这样做所需的工作量和关闭在每次调用的连接是个好习惯。

Only doing the work required and closing the connection on each call is good practice.

一件事你可以做的是的缓存的结果和不属于可能导致改变的数据在缓存项的生活调用返回缓存的结果。这将减少数据库调用。

One thing you can do is cache results and return the cached results for calls that are not likely to result in changed data over the life of the cache item. This will reduce database calls.

这篇关于最有效地获取SQL连接使用ASP.NET和Web服务时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆