romyd misc said:
> Hi Everyone,
>
> I'm developing an application using C# .NET and mysql as database. It's a
> multithreaded application, we open a mysql database connection at the very
> beginning when the application is started and all the database requests
> use
> the same connection. But under stress or when more than one request try to
> access database, i get "object reference errors". I don't get this error
> when frequency of database calls is low. Does it sounds like i need to
> implement connection pooling?
>
> I tried to lookup online, but couldn't find any help under mysql
> documentation. Can someone help me setting up mysql connection pooling
> with
> C#.NET.
>
> Thanks in advance,
> Romy
Your comment about one connection for all of the threads disturbs me.

Your application will have to ensure that each thread is finished with the
connection and returns it to the pool.  Two threads cannot, at the same
time, use the same connection.  Say thread A had performed a select which
returned 2000 row resultset.  Until that thread had read in all 2000 rows,
they would still be in the connection.  If thread B tried to use the same
connection and asked for a different result set when thread A went back
for the rest of its results where would they be?

When you put "stress" on your application this is more likely to happen.

What a pool does is allow your threads to formally release their
connections back to the pool when they are done with them and re-aquire
them later without the full overhead to going all the way back to the
server to open a connection.  Instead you go to some intermediate point
where a set of threads are already avaiable (in Apache its at the child
level and in java its at the container level).


Bill



-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]

Reply via email to