Kong / kong

🦍 The Cloud-Native API Gateway and AI Gateway.
https://konghq.com/install/#kong-community
Apache License 2.0
38.78k stars 4.77k forks source link

Feat(plugins/request-defer) #1479

Closed WALL-E closed 3 years ago

WALL-E commented 8 years ago

Recently I was developing a software firewall, I need a plugin to delay all http requests when the system is in an abnormal state, not limited or rejected, especially when doing “flash deal”

Two reasons

Others?

Tieske commented 8 years ago

have you seen #234?

WALL-E commented 8 years ago

@Tieske there could be significant difference, for example, plug-in doesn't have enough ability to judge the requestor is a robot or not, it needs to rely on a third-party, risk management or big-data.

Throttling algorithm seems rather coarsely.

sonicaghi commented 8 years ago

@WALL-E https://github.com/Mashape/kong/issues/154 ?

WALL-E commented 8 years ago

@sinzone no.

usually, the faster the server side is rejected, the faster the client(robot) request is sent, the result is that server load may be getting higher and higher.

This kind of situation often appears in the mainland of China, 京东 or 淘宝, similar to Amazon

WALL-E commented 8 years ago

the plugin's schema.lua may be like

return {
  fields = {
    deferred_execution_ millisecond = { default = 100, type = "number" }
  }
}
Tieske commented 8 years ago

Sorry, not getting the requested behaviour just yet.

I need a plugin to delay all http requests when the system is in an abnormal state, not limited or rejected,

Questions;

judge the requestor is a robot or not, it needs to rely on a third-party, risk management or big-data.

how does this fit into the way the plugin should work?

WALL-E commented 8 years ago

so the plugin should defer ALL requests?

Sorry, I may be a misnomer. Not all, only to meet certain conditions of the request

when should it start returning errors?

most of the time, do not return an error, just slow down the request

so you intent to use it as a devops tool? some monitoring tool triggers it and then you insert this plugin automatically through the management api? (and remove again when the situation normalizes)

no devops tool, but user behavior analysis

may be need two config option (For each user)

There are two roles