Home > Archive > ASP .NET > August 2007 > Can we use static table adapters in highly concurrent web sites?
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Can we use static table adapters in highly concurrent web sites?
|
|
| Max2006 2007-08-17, 7:19 pm |
| Hi,
I am trying to make our business logic layer components more efficient. We
use strongly typed datasets and TableAdapters.
Is it a good idea to use a static TableAdpater to share the static instance
among all sessions?
My business logic components are like this:
[DataObject]
public static class AccountBLL
{
private static ProfileTableAdapter m_ProfileTableAdapter = null;
private static ProfileTableAdapter AccountProfileTableAdapter
{
get
{
if (m_ProfileTableAdapter == null)
m_ProfileTableAdapter = new ProfileTableAdapter();
return m_ProfileTableAdapter;
}
}
[DataObjectMethodAttribute(DataObjectMet
hodType.Select, true)]
public static AppDataSet.ProfileDataTable GetAllProfiles()
{
AppDataSet.ProfileDataTable dt;
dt = AccountProfileTableAdapter.GetData();
return dt;
}
}
Whole sessions within the web application are going to share a single
instance of ProfileTableAdapter because it is static. I am a bit concern in
high concurrent situations. Is it safe?
Any help would be appreciated,
Max
| |
| bruce barker 2007-08-17, 7:19 pm |
| its a bad idea. you will need to add locking to your current code so
that only one call can run at a time or it will fail when concurrent
requests happen (connection is use errors).
you can still use static methods, but each method should create and
release its own tableadapter.
-- bruce (sqlwork.com)
Max2006 wrote:
> Hi,
>
> I am trying to make our business logic layer components more efficient. We
> use strongly typed datasets and TableAdapters.
>
> Is it a good idea to use a static TableAdpater to share the static instance
> among all sessions?
>
> My business logic components are like this:
>
>
> [DataObject]
> public static class AccountBLL
> {
> private static ProfileTableAdapter m_ProfileTableAdapter = null;
> private static ProfileTableAdapter AccountProfileTableAdapter
> {
> get
> {
> if (m_ProfileTableAdapter == null)
> m_ProfileTableAdapter = new ProfileTableAdapter();
>
> return m_ProfileTableAdapter;
> }
> }
>
> [DataObjectMethodAttribute(DataObjectMet
hodType.Select, true)]
> public static AppDataSet.ProfileDataTable GetAllProfiles()
> {
> AppDataSet.ProfileDataTable dt;
> dt = AccountProfileTableAdapter.GetData();
> return dt;
> }
> }
>
>
> Whole sessions within the web application are going to share a single
> instance of ProfileTableAdapter because it is static. I am a bit concern in
> high concurrent situations. Is it safe?
>
> Any help would be appreciated,
> Max
>
>
>
>
>
>
| |
| John Saunders [MVP] 2007-08-17, 7:19 pm |
| "Max2006" <alanalan1@newsgroup.nospam> wrote in message
news:uXGksBO4HHA.5160@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> I am trying to make our business logic layer components more efficient. We
> use strongly typed datasets and TableAdapters.
Have you done some profiling that suggests that your TableAdapters are a
significant source of poor performance?
If not, then don't touch them! Never optimize where you _think_ the
performance problem is. Don't solve the wrong problem.
Especially don't touch them by making them static, which means that multiple
requests will be using the same data at the same time.
--
John Saunders [MVP]
| |
| Max2006 2007-08-17, 7:19 pm |
|
Does this means that TableAdapter is not thread safe?
"Max2006" <alanalan1@newsgroup.nospam> wrote in message
news:uXGksBO4HHA.5160@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> I am trying to make our business logic layer components more efficient. We
> use strongly typed datasets and TableAdapters.
>
> Is it a good idea to use a static TableAdpater to share the static
> instance among all sessions?
>
> My business logic components are like this:
>
>
> [DataObject]
> public static class AccountBLL
> {
> private static ProfileTableAdapter m_ProfileTableAdapter = null;
> private static ProfileTableAdapter AccountProfileTableAdapter
> {
> get
> {
> if (m_ProfileTableAdapter == null)
> m_ProfileTableAdapter = new ProfileTableAdapter();
>
> return m_ProfileTableAdapter;
> }
> }
>
> [DataObjectMethodAttribute(DataObjectMet
hodType.Select, true)]
> public static AppDataSet.ProfileDataTable GetAllProfiles()
> {
> AppDataSet.ProfileDataTable dt;
> dt = AccountProfileTableAdapter.GetData();
> return dt;
> }
> }
>
>
> Whole sessions within the web application are going to share a single
> instance of ProfileTableAdapter because it is static. I am a bit concern
> in high concurrent situations. Is it safe?
>
> Any help would be appreciated,
> Max
>
>
>
>
>
>
|
|
|
|
|