static variables in data layer, via webservice
<p>I was asked to take over an application, which was running fine under 1-2 users testing it, but once we put it through a larger test, it started crashing. We're seeing random timeouts, along with messages about the code not being able to find certain columns that it expected to be there to bind to, though with just 1-2 users it was working.</p>

<p>The structure of the application is:</p>

<pre><code>--------------
| WebSite    |
--------------
| WebService |
--------------
| Database   |
--------------
</code></pre>

<p>The website does all communication with the database via the webservice. Looking through the webservice code, I saw it was using a class to do the database work, and had this declared as a class level variable:</p>

<pre><code>private static SqlConnection cn;
</code></pre>

<p>This was then being used in all the methods on the page that would need a connection. Being static, this mean there is just one instance for all users correct? I just want to confirm I'm seeing it correctly, as we removed it and are testing it now. Seeing that line to me means that 1 instance of the connection object was being shared amongst all users, which would explain why it was okay for 1-2 users, but the larger the number of users, the more people were queued waiting for it, eventually leading to the random errors. Just want to confirm I'm understanding this correctly.</p>

<p>Thanks.</p>
