Limit pageloads per second

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Terriator
Forum Commoner
Posts: 60
Joined: Mon Jul 04, 2005 12:46 pm

Limit pageloads per second

Post 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?
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Limit pageloads per second

Post 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.
Terriator
Forum Commoner
Posts: 60
Joined: Mon Jul 04, 2005 12:46 pm

Re: Limit pageloads per second

Post by Terriator »

That sounds pretty heavy on the database.. I have ~5 million pageviews per day..
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

Re: Limit pageloads per second

Post by Eran »

Where did you see database mentioned? I said in the session..
Post Reply