-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add overload manager to bootstrap config #4038
Changes from 3 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
load("//bazel:api_build_system.bzl", "api_proto_library_internal") | ||
load("//bazel:api_build_system.bzl", "api_go_proto_library", "api_proto_library_internal") | ||
|
||
licenses(["notice"]) # Apache 2 | ||
|
||
api_proto_library_internal( | ||
name = "overload", | ||
srcs = ["overload.proto"], | ||
visibility = ["//visibility:public"], | ||
) | ||
|
||
api_go_proto_library( | ||
name = "overload", | ||
proto = ":overload", | ||
) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,21 +8,30 @@ import "google/protobuf/struct.proto"; | |
|
||
import "validate/validate.proto"; | ||
|
||
// The Overload Manager provides an extensible framework to protect Envoy instances | ||
// from overload of various resources (memory, cpu, file descriptors, etc) | ||
// [#protodoc-title: Overload Manager] | ||
|
||
message EmptyConfig { | ||
} | ||
// The Overload Manager provides an extensible framework to protect Envoy instances | ||
// from overload of various resources (memory, cpu, file descriptors, etc). | ||
// It monitors a configurable set of resources and notifies registered listeners | ||
// when triggers related to those resources fire. | ||
|
||
message ResourceMonitor { | ||
// The name of the resource monitor to instantiate. Must match a registered | ||
// resource monitor type. | ||
// resource monitor type. The built-in resource monitors are: | ||
// | ||
// clang-format off | ||
// * :ref:`envoy.resource_monitors.fixed_heap <envoy_api_msg_config.resource_monitor.fixed_heap.v2alpha.FixedHeapConfig>` | ||
// clang-format on | ||
string name = 1 [(validate.rules).string.min_bytes = 1]; | ||
|
||
// Configuration for the resource monitor being instantiated. | ||
google.protobuf.Struct config = 2; | ||
} | ||
|
||
// Convenience protobuf for resource monitors that do not require any configuration. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need this? Can't we just use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup, added a helper EmptyConfigFactoryBase class for resources monitors with no configs that uses google.protobuf.Empty. |
||
message EmptyConfig { | ||
} | ||
|
||
message ThresholdTrigger { | ||
// If the resource pressure is greater than or equal to this value, the trigger | ||
// will fire. | ||
|
@@ -45,7 +54,7 @@ message OverloadAction { | |
// DNS to ensure uniqueness. | ||
string name = 1 [(validate.rules).string.min_bytes = 1]; | ||
|
||
// A set of triggers for this action. If any of these triggers fires the overload action | ||
// A set of triggers for this action. If any of these triggers fire the overload action | ||
// is activated. Listeners are notified when the overload action transitions from | ||
// inactivated to activated, or vice versa. | ||
repeated Trigger triggers = 2 [(validate.rules).repeated .min_items = 1]; | ||
|
@@ -59,5 +68,5 @@ message OverloadManager { | |
repeated ResourceMonitor resource_monitors = 2 [(validate.rules).repeated .min_items = 1]; | ||
|
||
// The set of overload actions. | ||
repeated OverloadAction actions = 3 [(validate.rules).repeated .min_items = 1]; | ||
repeated OverloadAction actions = 3; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,12 @@ syntax = "proto3"; | |
package envoy.config.resource_monitor.fixed_heap.v2alpha; | ||
option go_package = "v2alpha"; | ||
|
||
// [#protodoc-title: Fixed heap] | ||
|
||
// The fixed heap resource monitor reports the Envoy process memory pressure, computed as a | ||
// fraction of currently reserved heap memory divided by a statically configured maximum | ||
// specified in the FixedHeapConfig. | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: remove blank line. |
||
message FixedHeapConfig { | ||
// Limit of the Envoy process heap size. This is used to calculate heap memory pressure which | ||
// is defined as (current heap size)/max_heap_size_bytes. | ||
uint64 max_heap_size_bytes = 1; | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
.. _config_resource_monitors: | ||
|
||
Resource monitors | ||
================= | ||
|
||
.. toctree:: | ||
:glob: | ||
:maxdepth: 1 | ||
|
||
*/v2alpha/* |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,3 +21,4 @@ Configuration reference | |
runtime | ||
statistics | ||
tools/router_check | ||
overload_manager/overload_manager |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.. _config_overload_manager: | ||
|
||
Overload manager | ||
================ | ||
|
||
The overload manager is configured in the Boostrap | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe link "overload manager" back to the architecture overview intro. |
||
:ref:`overload_manager <envoy_api_field_config.bootstrap.v2.Bootstrap.overload_manager>` | ||
field. | ||
|
||
Resource monitors | ||
----------------- | ||
|
||
The overload manager uses Envoy's :ref:`extension <extending>` framework for defining | ||
resource monitors. Envoy's builtin resource monitors are listed | ||
:ref:`here <config_resource_monitors>`. | ||
|
||
Statistics | ||
---------- | ||
|
||
Each configured resource monitor has a statistics tree rooted at *overload.<name>.* | ||
with the following statistics: | ||
|
||
.. csv-table:: | ||
:header: Name, Type, Description | ||
:widths: 1, 1, 2 | ||
|
||
pressure, Gauge, Resource pressure as a percent | ||
failed_updates, Counter, Total failed attempts to update the resource pressure | ||
skipped_updates, Counter, Total skipped attempts to update the resource pressure due to a pending update | ||
|
||
Each configured overload action has a statistics tree rooted at *overload.<name>.* | ||
with the following statistics: | ||
|
||
.. csv-table:: | ||
:header: Name, Type, Description | ||
:widths: 1, 1, 2 | ||
|
||
active, Gauge, "Active state of the action (0=inactive, 1=active)" |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,3 +37,4 @@ Architecture overview | |
draining | ||
scripting | ||
ext_authz_filter | ||
overload_manager |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
.. _arch_overview_overload_manager: | ||
|
||
Overload manager | ||
================ | ||
|
||
The overload manager is an extensible component for protecting the Envoy server from overload | ||
with respect to various system resources (such as memory, cpu or file descriptors) due to too | ||
many client connections or requests. This is distinct from | ||
:ref:`circuit breaking <arch_overview_circuit_break>` which is primarily aimed at protecting | ||
upstream services. | ||
|
||
The overload manager is :ref:`configured <config_overload_manager>` by specifying a set of | ||
resources to monitor and a set of overload actions that will be taken when some of those | ||
resources exceed certain pressure thresholds. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -247,6 +247,12 @@ void InstanceImpl::initialize(Options& options, | |
|
||
loadServerFlags(initial_config.flagsPath()); | ||
|
||
// Initialize the overload manager early so other modules can register for actions. | ||
overload_manager_.reset(new OverloadManagerImpl( | ||
dispatcher(), stats(), | ||
bootstrap_.has_overload_manager() ? bootstrap_.overload_manager() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: you don't need the conditional here; if you write |
||
: envoy::config::overload::v2alpha::OverloadManager())); | ||
|
||
// Workers get created first so they register for thread local updates. | ||
listener_manager_.reset(new ListenerManagerImpl( | ||
*this, listener_component_factory_, worker_factory_, ProdSystemTimeSource::instance_)); | ||
|
@@ -403,6 +409,8 @@ RunHelper::RunHelper(Event::Dispatcher& dispatcher, Upstream::ClusterManager& cm | |
} | ||
|
||
void InstanceImpl::run() { | ||
overload_manager_->start(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If there's an easy way to validate this in the server tests with the mocked overload manager, that could be nice to check. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok, I moved this call to the RunHelper class so it can be tested. |
||
|
||
RunHelper helper(*dispatcher_, clusterManager(), restarter_, access_log_manager_, init_manager_, | ||
[this]() -> void { startWorkers(); }); | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this should be here :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without this clang-format suppression, it complains that the line is too long but fix-format splits the line like this:
// * :ref:
envoy.resource_monitors.fixed_heap // <envoy_api_msg_config.resource_monitor.fixed_heap.v2alpha.FixedHeapConfig>
which breaks documentation:
/source/generated/rst/api-v2/config/overload/v2alpha/overload.proto.rst:32:Inline interpreted text or phrase reference start-string without end-string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm confused how clang-format is running on RST or proto; I think we run our fix-format script on the protos, but I don't think Clang has any proto knowledge to contribute..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We run clang-format on protos. It has a proto mode.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed - realized I just needed to add a couple spaces to the ref comment so it could be parsed correctly by the docs generator.