简体   繁体   中英

How can I get an Oracle connection pool shared across all applications/virtual directories/versions in my IIS instance?

如何在IIS实例中的所有应用程序/虚拟目录/版本之间共享Oracle连接池?

Connection pools are managed by the .NET Framework and are unique per connection string. Therefore, if you are using the exact same connection string (including the user identity if you are using Windows Integrated authentication) it will share the connection pool.

If you run Performance Monitor you can add the counter '.NET Data Provider for Oracle' and choose the process (Eg w3wp.exe) to monitor the connection pool statistics.

If you have multiple virtual directories (sub-webs) they can share the same application pool (w3wp.exe process.) However, based upon a test harness I wrote and a little further investigation I see that each sub-web has it's own app domain within the same w3wp.exe worker process. This is visible when looking at the performance counter for the w3wp process.

Therefore, multiple sub-webs sharing the exact same connection string will create their own connection pool.

Therefore, one approach would be to have your data service layer hosted under a separate process which is shared amongst multiple sub-webs. One such approach would be to use a .NET serviced component (C# class inheriting from ServicedComponent and installed under COM+.)

I created a test harness and proved that this indeed will work and share the same connection pool from various sub-webs.

However, this approach provides a very low level of isolation and therefore makes your entire website vulnerable (single point of failure.)

If you are worried about the amount of resources that are being used by having multiple connection pools, you can always control this within your connection string. For example, set the maximum pool size for each individual application.

Connections are a per-AppDomain resource. You cannot share them across AppDomains for the fundamental reason that objects can only exist inside of one AppDomain.

Therefore, your request cannot be satisfied.

Why do you need this in the first place? This sounds like the XY-problem .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM