istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pilot/pkg/features/tuning.go (about)

     1  // Copyright Istio Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //     http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package features
    16  
    17  import (
    18  	"runtime"
    19  	"time"
    20  
    21  	"istio.io/istio/pkg/env"
    22  )
    23  
    24  // Define performance tuning related features here.
    25  var (
    26  	MaxConcurrentStreams = env.Register(
    27  		"ISTIO_GPRC_MAXSTREAMS",
    28  		100000,
    29  		"Sets the maximum number of concurrent grpc streams.",
    30  	).Get()
    31  
    32  	// MaxRecvMsgSize The max receive buffer size of gRPC received channel of Pilot in bytes.
    33  	MaxRecvMsgSize = env.Register(
    34  		"ISTIO_GPRC_MAXRECVMSGSIZE",
    35  		4*1024*1024,
    36  		"Sets the max receive buffer size of gRPC stream in bytes.",
    37  	).Get()
    38  
    39  	PushThrottle = func() int {
    40  		v := env.Register(
    41  			"PILOT_PUSH_THROTTLE",
    42  			0,
    43  			"Limits the number of concurrent pushes allowed. On larger machines this can be increased for faster pushes. "+
    44  				"If set to 0 or unset, the max will be automatically determined based on the machine size",
    45  		).Get()
    46  		if v > 0 {
    47  			return v
    48  		}
    49  		procs := runtime.GOMAXPROCS(0)
    50  		// Heuristic to scale with cores. We end up with...
    51  		// 1: 20
    52  		// 2: 25
    53  		// 4: 35
    54  		// 32: 100
    55  		return min(15+5*procs, 100)
    56  	}()
    57  
    58  	RequestLimit = func() float64 {
    59  		v := env.Register(
    60  			"PILOT_MAX_REQUESTS_PER_SECOND",
    61  			0.0,
    62  			"Limits the number of incoming XDS requests per second. On larger machines this can be increased to handle more proxies concurrently. "+
    63  				"If set to 0 or unset, the max will be automatically determined based on the machine size",
    64  		).Get()
    65  		if v > 0 {
    66  			return v
    67  		}
    68  		procs := runtime.GOMAXPROCS(0)
    69  		// Heuristic to scale with cores. We end up with...
    70  		// 1: 20
    71  		// 2: 25
    72  		// 4: 35
    73  		// 32: 100
    74  		return min(float64(15+5*procs), 100.0)
    75  	}()
    76  
    77  	DebounceAfter = env.Register(
    78  		"PILOT_DEBOUNCE_AFTER",
    79  		100*time.Millisecond,
    80  		"The delay added to config/registry events for debouncing. This will delay the push by "+
    81  			"at least this interval. If no change is detected within this period, the push will happen, "+
    82  			" otherwise we'll keep delaying until things settle, up to a max of PILOT_DEBOUNCE_MAX.",
    83  	).Get()
    84  
    85  	DebounceMax = env.Register(
    86  		"PILOT_DEBOUNCE_MAX",
    87  		10*time.Second,
    88  		"The maximum amount of time to wait for events while debouncing. If events keep showing up with no breaks "+
    89  			"for this time, we'll trigger a push.",
    90  	).Get()
    91  
    92  	EnableEDSDebounce = env.Register(
    93  		"PILOT_ENABLE_EDS_DEBOUNCE",
    94  		true,
    95  		"If enabled, Pilot will include EDS pushes in the push debouncing, configured by PILOT_DEBOUNCE_AFTER and PILOT_DEBOUNCE_MAX."+
    96  			" EDS pushes may be delayed, but there will be fewer pushes. By default this is enabled",
    97  	).Get()
    98  
    99  	ConvertSidecarScopeConcurrency = env.Register(
   100  		"PILOT_CONVERT_SIDECAR_SCOPE_CONCURRENCY",
   101  		1,
   102  		"Used to adjust the concurrency of SidecarScope conversions. "+
   103  			"When istiod is deployed on a multi-core CPU server, increasing this value will help to use the CPU to "+
   104  			"accelerate configuration push, but it also means that istiod will consume more CPU resources.",
   105  	).Get()
   106  
   107  	MutexProfileFraction = env.Register("MUTEX_PROFILE_FRACTION", 1000,
   108  		"If set to a non-zero value, enables mutex profiling a rate of 1/MUTEX_PROFILE_FRACTION events."+
   109  			" For example, '1000' will record 0.1% of events. "+
   110  			"Set to 0 to disable entirely.").Get()
   111  
   112  	StatusUpdateInterval = env.Register(
   113  		"PILOT_STATUS_UPDATE_INTERVAL",
   114  		500*time.Millisecond,
   115  		"Interval to update the XDS distribution status.",
   116  	).Get()
   117  
   118  	StatusQPS = env.Register(
   119  		"PILOT_STATUS_QPS",
   120  		100,
   121  		"If status is enabled, controls the QPS with which status will be updated.  "+
   122  			"See https://godoc.org/k8s.io/client-go/rest#Config QPS",
   123  	).Get()
   124  
   125  	StatusBurst = env.Register(
   126  		"PILOT_STATUS_BURST",
   127  		500,
   128  		"If status is enabled, controls the Burst rate with which status will be updated.  "+
   129  			"See https://godoc.org/k8s.io/client-go/rest#Config Burst",
   130  	).Get()
   131  
   132  	StatusMaxWorkers = env.Register("PILOT_STATUS_MAX_WORKERS", 100, "The maximum number of workers"+
   133  		" Pilot will use to keep configuration status up to date.  Smaller numbers will result in higher status latency, "+
   134  		"but larger numbers may impact CPU in high scale environments.").Get()
   135  
   136  	XDSCacheMaxSize = env.Register("PILOT_XDS_CACHE_SIZE", 60000,
   137  		"The maximum number of cache entries for the XDS cache.").Get()
   138  
   139  	XDSCacheIndexClearInterval = env.Register("PILOT_XDS_CACHE_INDEX_CLEAR_INTERVAL", 5*time.Second,
   140  		"The interval for xds cache index clearing.").Get()
   141  )