"Thygesen" <thyge@get2net.dk> skrev i en meddelelse
news:3a9b8781@news.carlbro.dk...
> ".: DME :." <eliaa@usa.net> skrev i en meddelelse
> news:4IJl6.21026$PC4.854917@news010.worldonline.dk...
> > Tag en kig på denne artikel:
> >
>
http://www.netcoders.dk/articles.asp?mode=show_article&article_id=93&tech_id
> > =1
>
> Tak for det, men kan ikke få det til at virke under IIS/4.0 og han
anbefaler
> også at man kun bruger det under ISS5.
>
> Så jeg er i gang med at lave mit eget.
Hej
Der findes en ikke-optimeret version der kun benytter een application
variabel her:
http://aspfree.com/authors/josh_painter/activeusers.asp
Men den er stadig ikke særligt pænt implementeret, og han benytter en
standard timeout tid på 20 minutter, hvor 2 som du bruger er meget bedre.
Den er dog pænere end den der på Netcoders efter min mening.
Her er nogle kommentare jeg havde til forfatteren af scriptet i en
diskussion vi havde:
---------- start kommentar -------------
Suggestions/comments:
1) One might make this alteration: don't update the "last page view
timestamp" simply do the cleanup first (only once every minute of course)
and the insert afterwards.
Or better yet: Simply insert when the sessionID is not there set expiration
time to 15 minutes and clean up every 5 minutes. This makes your expiration
time about 15 to 20 minutes instead of 20 to 21 minutes at it is now. The
inaccuracy will provide you with 5 times
less running on the cleanup routine.
2) A default setting of 5 minutes timeout would be better. Most users don't
wait more than 5 minutes between page requests. The most correct setting to
use would be an average of the time between a users page views. Use this
possibility, you've already gone to the trouble of implementing a counter
that doesn't rely on the expiration of the users session.
3) Be aware that there might be some issues with scaleability:
If you have 10.000 unique visits in a 20-minute time span your string
would be:
(Len(Session.SessionID)+Len(<<average timestamp>>) +1 ) * 10.000
In your article this is 30 characters * 10.000.
That gives a string of at least 300.000 characters that you:
a) Traverse for each page view to see if the session ID exists (inside an
Application.Lock)
b) Concatenate (redim) every time a new user enters
c) Traverse and modify every minute at some random users page view
4) Why not use a session variable to avoid doing a) more than once per
session?
5) b) Can be changed to linear complexity by allocating more space than
needed by doubling/halving the space as needed. If you use strings then
allocate a string too large and use the Mid function for inserting new data.
Double the size when you need more space.
6) be aware that in a load balanced web farm (This goes for all "Active
Users" counters not just yours),
- The counters would be there.
- Your code would not produce errors.
- The counters would be wrong. (Only count active users on the current
front-end)
Because each front-end has it's own set of application variables.
Hope you can use this feedback,
Kind Regards,
Allan Ebdrup
--------------- slut kommentar ---------
Dertil kommer diskussion om cookies i kombination med IP numre for at sikre
at tælleren ikke tæller op hele tiden når en bruger ikke tillader session
cookies.
MVH
Allan Ebdrup, 10-4
www.ti-fire.dk