Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

concurrent users

Status
Not open for further replies.

logi2000

Programmer
Jun 17, 2003
221
CR
i have a web page that makes a query to a table, many users will be accesing that page.
if 2 or more users call the page at the same time, will one page is going to be process before the other, or do they are process exactly at the same time.

how is this manage in ASP.NET ?
 
the query returns 1 row from a customer table, the row has a column 'times' which tells how many times that row has been access, every time a record is retrieve, i increment the time column by one.

the query is like this to retrieve the values:

"select top 1 clientid, clientename from clients
order by times desc "

after the record is retrieve, i update the table

"
update clients set times = times + 1
where clientid = varclientid
"

even doing this, is it possible for more than one user to be accesing the same record ?
 
IIS maintains each user request in a seperate thread. So yes, it's possible for two people to access the same record at the same time. Doing a SELECT can result in stale data. Doing UPDATEs can result in one of them being a victim of a deadlock. You will need to code for these possibilities.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
But the chances that 2 users trying to update the same record at the very same time, is somewhat remote.

In the example you give, there theoretically, would be one clientid for each user and that user would only be able to update that particular record if he were logged in -- assuming that your program fetches the client's ID when he logs in.

The sql statement looks like you are trying to track the times a certain user logs in or accesses a certain page(s). In this particular case, if this IS the case, then it looks as though it would be very difficult to have concurrency issues, more than one user has the same clientid.

If you had multiple records with the same clientid then your counter would update multiple records for the same client. I would guess then that clientid is a unique number for each clientname.

I can't see this causing concurrency issues.
 
client id is unique. the client id is retrieve from the table when the user opens the aspx page, and the table column is updated right after obtaining the client id.

i want to track how many times a record has been opened, not how many times the page have been accesed.
 
While the chances of two users updating the same record are remote, depending on how your database does it's locking, you might actually hit a lock on the DB Page where the record is -- if each DB Page contains 10 records, your chances of getting blocked are much higher.

Chip H.


____________________________________________________________________
If you want to get the best response to a question, please read FAQ222-2244 first
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top