duancai7568 2011-10-24 18:14
浏览 50
已采纳

PHP sleep()是否为多个用户加起来?

Does the sleep() function add up for all the user using example.php through an ajax request?

If i put sleep(2) in example.php; do all user get afftected/add up sleep()?

I basicly want to limit requests for example.php, without using unsecure javascript, instead inside the php. Thanks

  • 写回答

5条回答 默认 最新

  • dqfaom241360 2011-10-24 18:18
    关注

    No. The sleep(2) will only affect the single user. However, if you want to do rate limiting, this is still not a great way to go about it.

    A malicious user could theoretically open up 1,000 simultaneous requests to example.php and in 2 seconds, have it executed 1,000 times. If requests are overlapped, this could theoretically be executed as many times per second as the attacker wants (up to the capacity of the server of course).

    As an alternative, you may want to look at something like the generic cell rate algorithm. The general idea with rate limiting is to throw away requests which go over the limit as efficiently as possible.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

悬赏问题

  • ¥15 python的qt5界面
  • ¥15 无线电能传输系统MATLAB仿真问题
  • ¥50 如何用脚本实现输入法的热键设置
  • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
  • ¥30 深度学习,前后端连接
  • ¥15 孟德尔随机化结果不一致
  • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
  • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
  • ¥15 谁有desed数据集呀
  • ¥20 手写数字识别运行c仿真时,程序报错错误代码sim211-100