-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
hotfix(mashape-analytics) improve ALF buffer under load
As reported by #750, the buffer is vulnerable to a heavy load because of its `sending_queue` of batches pending for sending. It also does not handle the new 207 HTTP status code returned by the collector in case of invalid ALFs. Changes: - handle 207 HTTP status code by discarding the batch. Some ALFs in it will have been saved, and the invalid one(s) should not be retried. - implement a maximum size (in MB) for the sending_queue, as suggested by #750. Originally, I was about to implement such a size limitation by "number of batches pending", but it would not be intuitive for users to know what fits best their use case, because ALF sizes varies from one API to another, and one endpoint to another. By defining it in MB it is easier for users to chose a value. The default value of 10MB has been chosen after performing some benchmarking, and should handle from 300 to 500 req/s depending on the ALFs sizes. When the `sending_queue` has reached its limit, the current ALFs in the buffer will be **discarded**. - implement a retry policy. Instead of insisting on retrying to send batches when the collector cannot be reached, a delay is computed an exponentially increases on each failure to connect to the collector. That delay is shared by all workers. This avoids to load the collector when it is having difficulties and saves up bandwidth on Kong's side. As soon as the collector can be reached again, the delay is reset. Currently, the minimum retry delay is 1s and the maximum is 60s. Those values cannot be configured. - no more line jumps in logs printing responses from the collector.
- Loading branch information
1 parent
b4cc76a
commit 87e15dd
Showing
4 changed files
with
279 additions
and
97 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
return { | ||
fields = { | ||
service_token = { type = "string", required = true }, | ||
environment = { type = "string" }, | ||
batch_size = { type = "number", default = 100 }, | ||
log_body = { type = "boolean", default = false }, | ||
delay = { type = "number", default = 2 }, | ||
host = { required = true, type = "string", default = "socket.analytics.mashape.com" }, | ||
port = { required = true, type = "number", default = 80 }, | ||
path = { required = true, type = "string", default = "/1.0.0/batch" } | ||
service_token = {type = "string", required = true}, | ||
environment = {type = "string"}, | ||
batch_size = {type = "number", default = 100}, | ||
log_body = {type = "boolean", default = false}, | ||
delay = {type = "number", default = 2}, | ||
sending_queue_size = {type = "number", default = 10}, -- in mb | ||
host = {required = true, type = "string", default = "socket.analytics.mashape.com"}, | ||
port = {required = true, type = "number", default = 80}, | ||
path = {required = true, type = "string", default = "/1.0.0/batch"} | ||
} | ||
} |
Oops, something went wrong.