Reply to Re: How do I limit my number of PHP hits per second?

Your name:

Reply:


Posted by Peter Fox on 02/01/07 09:35

Following on from Nu's message. . .
>I am trying to limit how often index.php gets run. Index.php calls lots of
>other stuff. I want (even in index.php) to just like if it's run too often
>per so many seconds, to just stop and that's enough for now. It's not about
>a complicated IP tracking thing, just a simple thing.

OK.[1] You simply want to say "I will only allow index.php to be run
10(etc) times per second."
(1) I don't know if there is an Apache way to do this so I'll pass on
that one.
(2) If you can't stop the page running you can stop it doing lots of
complicated work by sharing the data across all sessions for which you
need to persist in a shared resource such as a database or mutex file.
(3) There are various things you can do in the "do I allow another
proper execution or fail[2]"
- Every 100 runs reset mutex to 0 // stops errors building up to
wedge
the system.
- Check a counter of how many are 'in progress'
- If OK then add 1 to mutex and do real work or fail
- At end subtract 1 from mutex[3]

[1] Personally I think it is better to get to the root cause of the
problem and if you can't ask people 'not to do that' then to enforce it
/for those people/. If you're the national rail site that falls over
when there's a bit of snow and everyone wants to see what a shambles the
railways are in then get more server power.

[2] You need to give very careful thought to how you 'fail'. Delay, 500
message, bandwidth exceeded graphic, absolutely no output, Forbidden?,
redirect to static data in a HTML page ...

[3] Notice I have bent your spec in this scheme and looked at the number
of sessions currently running rather than an arbitrary time between
calls.


--
PETER FOX Not the same since the bolt company screwed up
peterfox@eminent.demon.co.uk.not.this.bit.no.html
2 Tees Close, Witham, Essex.
Gravity beer in Essex <http://www.eminent.demon.co.uk>

[Back to original 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

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