Re: Q:Multithreaded ADO.Net Connections Are Non Pooled?
- From: "William \(Bill\) Vaughn" <billvaRemoveThis@xxxxxxxxxx>
- Date: Wed, 6 Jul 2005 09:19:03 -0700
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
>>
>>
>
.
- Follow-Ups:
- Re: Q:Multithreaded ADO.Net Connections Are Non Pooled?
- From: Pablo Castro [MS]
- Re: Q:Multithreaded ADO.Net Connections Are Non Pooled?
- References:
- Q:Multithreaded ADO.Net Connections Are Non Pooled?
- From: Marauderz
- Re: Q:Multithreaded ADO.Net Connections Are Non Pooled?
- From: William \(Bill\) Vaughn
- Re: Q:Multithreaded ADO.Net Connections Are Non Pooled?
- From: Marauderz
- Q:Multithreaded ADO.Net Connections Are Non Pooled?
- Prev by Date: Update Dataset Not working
- Next by Date: Re: Persist Security Info = True in connection string
- Previous by thread: Re: Q:Multithreaded ADO.Net Connections Are Non Pooled?
- Next by thread: Re: Q:Multithreaded ADO.Net Connections Are Non Pooled?
- Index(es):
Relevant Pages
|