You are here: Re: How do I limit my number of PHP hits per second? « PHP Programming Language « IT news, forums, messages
Re: How do I limit my number of PHP hits per second?

Posted by Sanders Kaufman on 02/01/07 00:25

Nu wrote:
> "Sanders Kaufman" <bucky@kaufman.net> wrote in message

>> That's usually an OK design flaw behind a firewall, but not out
>> in open water.
>
> So how do I handle peak loads and exit gracefully during overloads?
>
> Basically something like X hits per 10 seconds to index.php sounds simple
> enough. I can't find out how to do that, though.

Now THAT is a question a coder can answer!!!
There are several approaches.

I would use a timestamp/hitcount $_SESSION[] variable to track
their usage.

Then, each session will be aware of how often its client is
hitting you - aborting the connection (but not the session!)
when they're outside of your desired frequency.

Me, personally, I wouldn't abort the connection. I'd put them
to sleep. There's a sleep() function in PHP that will let you
pause the processing for a period of time. (You might want to
build a wrapper around it for your own sleepy purposes.)

This will also force bot/agents into throttling down their
requests. Since the connection isn't broken, they won't issue a
zillion connection requests. They'll just thing you've got one
seriously bogged down machine.

It might even trick them into thinking they DoS'd you - when in
fact, you DoS'd them.

You can't force people to behave any certain way on the web -
but you can trick their software!



Rule #1 of dealing with coders - don't ask *them* for the spec.

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация