Re: Q:Multithreaded ADO.Net Connections Are Non Pooled?



You can tell by picking up the ProcessID as you execute... if the PID is
different you get a new pool.
Simple threading from a single process should share the same pool, but
remember you can't share connections across threads until 2.0 and then you
still have to serialize (MARS).

--
____________________________________
William (Bill) Vaughn
Author, Mentor, Consultant
Microsoft MVP
www.betav.com/blog/billva
www.betav.com
Please reply only to the newsgroup so that others can benefit.
This posting is provided "AS IS" with no warranties, and confers no rights.
__________________________________

"Marauderz" <marauderz@xxxxxxxxxx> wrote in message
news:O18hZ6cgFHA.3936@xxxxxxxxxxxxxxxxxxxxxxx
> Thanks for the answers guys.
>
> Now that I have a better understanding on how the connections are being
> pooled I might be able to find out the main cause of the problem. As for
> the process/app domain differences, does running on a thread created by
> QueueUserWorkItem means that a new app domain/process gets created? I
> don't think so right?
>
> Thanks again.
>
> ----------
> "William (Bill) Vaughn" <billvaRemoveThis@xxxxxxxxxx> wrote in message
> news:u9epA0agFHA.2424@xxxxxxxxxxxxxxxxxxxxxxx
> Oops... pressed Send too soon.
> First, the connection pool is designed to pool connections using:
> The same ConnectionString
> The same credentials. If you're using SSPI, each connection must be
> opened "by" the same login.
> The same transaction context
> The same transaction "enlistment" state
> The same MARS state (2.0 only)
> The same process/app domain. I expect this is where you might be having
> problems.
> Ok, let's assume that all of the above are the same. The connection pool
> will only share "idle" connections--those that have been opened, used and
> (most importantly close) BEFORE another request comes in. If there is no
> pooled connection available, another is added to the pool. If the
> aforementioned factors change, a new pool is created based on the settings
> used. I also suspect you might be overloading the server. The profiler and
> perfmon can monitor the connections and pools (as I describe in my ADO.NET
> books).
>
> hth
>
> --
> ____________________________________
> William (Bill) Vaughn
> Author, Mentor, Consultant
> Microsoft MVP
> www.betav.com/blog/billva
> www.betav.com
> Please reply only to the newsgroup so that others can benefit.
> This posting is provided "AS IS" with no warranties, and confers no
> rights.
> __________________________________
>
> "Marauderz" <marauderz@xxxxxxxxxx> wrote in message
> news:ujjeeqYgFHA.2180@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi guys, have a little weird scenario here.
>>
>> I have a windows Service that's serving requets using multiple threads
>> created by the .Net threadpool. Within each thread they will create their
>> own Connection object and go off and do their thing, an insert, a Select
>> and
>> the connection is closed.
>>
>> The SQL Server which the service communicates with lies on a different
>> physical machine.
>>
>> Now this service is basically hammered.. about 20 hits per second. And
>> when
>> I run TCPView I see that a LOT of ports have been opened by my service to
>> connect to the SQL Server machine, wasn't connection pooling supposed to
>> use
>> only one?
>>
>> I decided to run some test myself and wrote a seperate test program that
>> just updates the database using threads created by the thread pool.
>> According to the performance monitor The connections that were created by
>> the threads all seem to fall under the non pooled thread category.
>>
>> Does anyone have an explanation why the threads aren't pooled? And what I
>> should do to err.. correct this situation?
>>
>> Thanks
>>
>>
>


.



Relevant Pages

  • Re: Q:Multithreaded ADO.Net Connections Are Non Pooled?
    ... code running as a result of calling QueueUserWorkItem will ... To minimize pool fragmentation you need to make sure all the thing Bill ... pointed below are the same (connection string, NT identity, etc.) ... >> the process/app domain differences, does running on a thread created by ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: SQL Statement Class Helper request
    ... SQL Server will do this as well for regular queries issued ... > connection (there is also the notion of "preparing" a query for use multiple ... One advantage of using Java for the connection pool - this doesn't seem ... > I agree with you that there are ways you might want to filter the query. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Close and Dispose argument
    ... > fact that even Microsoft is not clear on the issue. ... > connections from the pool is still a debate. ... > method removes the conneciton from the connection pool". ... > Your issue was forwarded to us here at Microsoft Courseware Support. ...
    (microsoft.public.dotnet.framework.adonet)
  • Close and Dispose argument
    ... here is an email conversation between me and Microsoft ... connections from the pool is still a debate. ... Programming with Microsoft ADO.NET" module 2, p 18: "Calling the Dispose ... method removes the conneciton from the connection pool". ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Connection pool count too high?
    ... > just the connection string that determines if a new pool is needed. ... > (app domain) gets its own pool, but within that scope each transaction gets ... >> Our web application is all asp.net, using ADO.NET and SQL Server 2000 STD. ...
    (microsoft.public.dotnet.framework.adonet)