NYCPHP Meetup

NYPHP.org

[nycphp-talk] Experts help needed (Sessions)

Chris Shiflett shiflett at php.net
Sat Aug 6 17:27:33 EDT 2005


Joseph Crawford wrote:
> I appreciate your thoughts on the User Agent, maybe i will have to
> implement that type of tracking but i also think that if i compare the
> current user agent to an array of the last 100, wont that be time
> consuming and resource intensive

George is the performance guy. :-)

Yes, any safeguard is going to cost you some performance. I think this 
is fine as long as long as the negative impact of a safeguard has a 
linear correlation to your traffic. Exponential costs will kill you.

For example, in this case, you could check against each user agent sent 
in the past requests for the current session, and this would be awful. 
Every time a user requests a page, the performance impact is higher than 
it was for the previous requests, because the cost is accumulating.

A better approach would be to check an integer - whenever a user agent 
matches, you increment a counter. After a certain threshhold of your 
choosing, you can begin enforcing user agent consistency. Checking to 
see whether 7919 is greater than 50 is comparable to checking to see 
whether 100 is greater than 50. Thus, while the safeguard has a 
performance cost, it's a consistent one.

Hope that helps.

Chris

-- 
Chris Shiflett
Brain Bulb, The PHP Consultancy
http://brainbulb.com/



More information about the talk mailing list