I ran into an issue when trying to figure a way to diplay a list of users and their department who were viewing a page. I used the request.logonuseridentity.name value to pass to a stored procedure that looked up the department of the user in a table then updated an activity datetime field so the page could list the active users along with the department of which they belonged. When one user was on the page, the timer updated the activity every second. When several users were on the page, it took up to 30 seconds. I can only guess the stored proc is being hit too often?
I feel like I am making this task harder than what it needs to be. Does anyone know how I can get a list of request.logonuseridentity.name (or similar result) actively viewing a page passed to SQL Server or perhaps why the time has an issue when several people are using it as I have it setup?
Thanks!
Hi,
According to your description, I think it's a problem of scalability of your application. When the number of user increases, and each of them sends a request per second, and subsequently incur a database access, it's definitely a heavy burden.
I have following suggestions:
1. If the the statistics doesn't have to be realtime, please increase the interval
2. Use cache to keep current logged on users, so that no database access is required
As Raymond said, you should definitely consider increasing the interval. I doubt that anyone really needs to know or cares precisely what user activity has happened in the last second. 30 seconds and higher are common caching intervals for that sort of information. In fact, most of the "Who's online" displays you see on message boards are only updated every 5-10+ minutes.
As far as increasing the speed of the actual update, consider using page methods instead of a Timer and partial postback. Since it's a read-only operation, there's not much reason to use thedangerously inefficient partial postback. You could return a string array of online usernames from a page method and increase performance over the Timer/UpdatePanel setup by orders of magnitude.
Thank you for the replies. I have had difficultly searching for how to implement your suggestion of using page methods for this purpose. Can you provide any links to help with this?
Thanks!
The link in my post above has an example of implementing a page method call to replace an UpdatePanel.
No comments:
Post a Comment