On my small site I have to throttle user demands for a number of reasons:

  • Prevent overquerying of database or third party apis
  • Prevent junk e-mail
  • Stopping others from scraping my data

I'm wondering exactly what the guidelines are for throttling? If it is done in the script level (PHP/MySQL) or in the server level (Apache)?

And what are the specific guidelines I ought to bear in mind in relation to throttling?

This will ideally be achieved in the network / firewall level or at the minimum on Apache.

PHP throttling can be done too, however it should simply be done if you wish to deny the accessibility resource and not simply stalling. Make reference to this answer (and comments) I gave inside a similar question for additional particulars:

off the top my mind, you will find a few that you desire to think about using:

1) You could utilize JavaScript to produce times that sets flags to ensure that you should check back using the flag to make sure that they do not request inside the interval period.

2) You could utilize PHP and store their demands amount of time in the session that you are running and appearance against that to ensure that they do not make demands too often.

3) You could utilize MySQL to log when their last access time was and find out if they must be permitted to make use of the resource.

Generally these techniques are split into client side and server side. Deploy whichever you are feeling preferred with and it is easiest on your own.

Not every deployments permit you to customize the Apache Server config :)

Hope it will help. Cheers!