johnmc33
asked on
Threading in a Web App - Shared Hosting Environment
Hi,
I have a .NET 2.0 web application on shared hosting environment which is hooked to a SQL Server 2005 database.
I want to give my users an instant response and let a thread handle the processing in the background. The design in place does the following:
For each user who logs into site this will happen
{
1. User logs into site and creates X messages.
2. Write each message to a record to a MessageQ table for this user in database
3. Return control to user and start a thread which reads MessageQ entries for this user and processes.
}
My question is.. ... Does this design look ok?
Each user accessing the system will create a thread for their messages so potentially N users could have N threads all accessing the MessageQ table at the same time.
That is my concern.
John
I have a .NET 2.0 web application on shared hosting environment which is hooked to a SQL Server 2005 database.
I want to give my users an instant response and let a thread handle the processing in the background. The design in place does the following:
For each user who logs into site this will happen
{
1. User logs into site and creates X messages.
2. Write each message to a record to a MessageQ table for this user in database
3. Return control to user and start a thread which reads MessageQ entries for this user and processes.
}
My question is.. ... Does this design look ok?
Each user accessing the system will create a thread for their messages so potentially N users could have N threads all accessing the MessageQ table at the same time.
That is my concern.
John
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That sounds just right. I often do a check every once in a while to check the thread is still running. e.g. on each request.
ASKER
and finally ...
As more than 1 user request could be writing to the messageQ table at the same time, I have made all inserts statements to the messageQ table using transactional stored procedures.
This means writing the to table will be threadsafe .... right?...
Thank you so much for the help on this.
As more than 1 user request could be writing to the messageQ table at the same time, I have made all inserts statements to the messageQ table using transactional stored procedures.
This means writing the to table will be threadsafe .... right?...
Thank you so much for the help on this.
If its a single insert then you should be safe anyhow but no harm in doing things fully.
ASKER