开发者

What is the best way to prevent visitors from excessively requesting resource-consuming pages?

开发者 https://www.devze.com 2023-01-31 13:20 出处:网络
I am a newbie and trying to develop a Yellow-Pages like portal using ASP.NET MVC. I am wondering there will be some bad visitors who excessively request the portal pages to slow down my portal and to

I am a newbie and trying to develop a Yellow-Pages like portal using ASP.NET MVC. I am wondering there will be some bad visitors who excessively request the portal pages to slow down my portal and to block request from other legitima开发者_如何学运维te visitors.

My current idea is put a nugget (an embedded code block) in master page to check the interval between two consecutive request. If the interval is less than 5 seconds (for example), I will reject/terminate to render the request.

My question:

  1. What is the best way to handle this issue?
  2. If my idea above is applicable to solve this issue, what function must I call to terminate the rendering process (before doing resource-intensive job)?

EDIT 1:

  1. Can we set this on server (IIS settings) globally instead of per application basis?


If you are serving up read-only pages, then proper caching is your first line of defense. You can limit requests by IP, but that would necessitate another form of look-up.

Using any form of client control like adding a date entry to the master page is pointless if an attacker can side-step or remove it.

If you need to limit posts to a submission form, then you should start looking at authenticating users first and issuing tokens that allow one submission and refuse to issue a new token unless a certain time span has elapsed since the last token was issued.

Focus on making your site fast first.


Re 1: make sure your pages render fast, use output cache. Get enough server power to handle visitors.

Re : Yes. it would also make sure people that are fast get blocked. Gratulations. Makes sense, but you ened t obe faster (0.1 seconds or something like that).


I would do this via doughnut hole cache

0

精彩评论

暂无评论...
验证码 换一张
取 消