并发 - java如果打回相差几毫秒的请求
伊谢尔伦
伊谢尔伦 2017-04-18 10:55:18
0
2
572

1.有一个用户在10毫秒内提交了两个请求.前端已经上了应用市场,所以改不了,只能从java下手.
请问怎么设计能将第二个请求直接打回?并且需要考虑并发情况

补充:如果需要对所有的接口都进行这种过滤,请问需要如何设计?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(2)
左手右手慢动作

Write an interceptor and filter it. For filtering two consecutive times separated by more than 10ms

PHPzhong

There is a concept in PHP's laravel framework, which is middleware. You can filter all requests with the specified middleware first.

But it is estimated that in your current situation, you will need to use an in-memory database. Encode the content of the request and insert it into the library (plus the request time field). When responding to the request, first check whether there is a request with the same encoding. If there is no response to the request, if so, compare the time difference before processing.

Users who request too frequently can be added to the blacklist.

Of course, a necessary condition for this is that the user can be identified in the requested content, otherwise it will be difficult.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template