Throttling

Every once in a while someone makes a site that becomes wildly popular. Having loads of people visiting a site can put some serious strain on the server's resources and cause all sorts of problems as the congestion builds. Even if a site is not exceedingly popular, it is possible that it may come under a denial of service attack from somewhere.

Before even thinking about setting up the throttling mechanism on a site, it is important that you know what resources are at your disposal:

Note

If you have already ensured that there are facilities in place to handle a large amount of traffic, then you have made the throttle module redundant in effect.

If you are unsure about what resources are available on your site, check with the hosting service and find out what they are giving you.

Assuming you anticipate there will be a need for some sort of congestion control, a good way to deal with surges in traffic or bandwidth usage is to enable the throttling mechanism that comes with Drupal, in the form of the aforementioned throttle module. This is easy enough to accomplish by enabling it in the modules section of the administration tool. Once that is done, you can configure how the module acts on the site in general by navigating to the throttle page under settings in the administration area. This will bring up the following page:

Throttling

This page deals with congestion from the point of view of how many people are using the site. In this case, Drupal is instructed to engage the auto-throttle on anonymous users provided there are 300 or more online, and the same for authenticated users provided there are more than 100 of them online. The final option deals with actually limiting the amount of work the throttle mechanism has to do so that it itself does not become a resource hog.

But what if you know that it is a specific module that is consuming more than its fair share of resources? In this case, you would simply enable the auto-throttle for that specific module in the modules section of the administration tool, as shown here:

Throttling

This can be done on a block-by-block basis as well, by navigating over to the blocks section and doing the same thing. But what does throttling blocks ultimately mean? Basically, if your server is under strain and you have set a block to be automatically throttled, it will be disabled and not contribute to the load on the server.

You can take a look at your log message to determine what the throttle module is up to at any given time. For example, I set the throttle mechanism to engage after only one user visited the site. The following log message was then created:

Throttling

It's not much, but at least it makes it clear when the throttle is on. Once the load has dropped sufficiently, a corresponding message will be sent stating that the throttle can be disengaged and things can return to normal.

While this next point is not directly related to throttling, it is important that you gain some idea about the performance of your site and what you can do to ensure it is good. Take a look at http://drupal.org/node/2601 to learn about how to:

  • Analyze your site's performance
  • Reduce the load on your servers by preventing access to certain parts of your site for web crawlers of various kinds, using the robot.txt file
  • Learn about Apache performance and PHP and MySQL tuning

Any knowledge you gain now can be put to good use preemptively to guard against poor performance which may discourage users in the future—even though it is unlikely that you will notice any performance-related issues early on.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.134.102.182