Page 1 of 1

Limit pageloads per second

Posted: Sun Nov 30, 2008 4:35 am
by Terriator
I'm in need of a script, which ensures that each user, when logged in, cannot load more than 2 pages per second; if he does, he should get some error message.

What would be the smartest and most efficient/resource-saving way of achieving this limitation?

Re: Limit pageloads per second

Posted: Sun Nov 30, 2008 4:53 am
by Eran
Store a timestamp array (microtime()) of the pages visited in the session. If the current page has been visited more than twice in the last second, redirect to an error page instead.

Re: Limit pageloads per second

Posted: Sun Nov 30, 2008 5:02 am
by Terriator
That sounds pretty heavy on the database.. I have ~5 million pageviews per day..

Re: Limit pageloads per second

Posted: Sun Nov 30, 2008 5:11 am
by Eran
Where did you see database mentioned? I said in the session..