mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-11-21 14:44:00 +00:00
protection vmselect ,avoid metrics point too much let vmselect cup load very, very high (#1478)
* protection vmselect…… * protection vmselect…… * protection vmselect…… * All checks have failed,fix Co-authored-by: lirenzuo <lirenzuo@shein.com>
This commit is contained in:
parent
857fa4e28a
commit
626073bca8
1 changed files with 9 additions and 1 deletions
|
@ -29,6 +29,7 @@ var (
|
|||
maxTagValuesPerSearch = flag.Int("search.maxTagValues", 100e3, "The maximum number of tag values returned per search")
|
||||
maxTagValueSuffixesPerSearch = flag.Int("search.maxTagValueSuffixesPerSearch", 100e3, "The maximum number of tag value suffixes returned from /metrics/find")
|
||||
maxMetricsPerSearch = flag.Int("search.maxUniqueTimeseries", 300e3, "The maximum number of unique time series each search can scan")
|
||||
maxMetricsPointSearch = flag.Int("search.maxMetricsPointSearch", 300e3, "control search metrics point number")
|
||||
|
||||
precisionBits = flag.Int("precisionBits", 64, "The number of precision bits to store per each value. Lower precision bits improves data compression at the cost of precision loss")
|
||||
disableRPCCompression = flag.Bool(`rpc.disableCompression`, false, "Disable compression of RPC traffic. This reduces CPU usage at the cost of higher network bandwidth usage")
|
||||
|
@ -1070,13 +1071,20 @@ func (s *Server) processVMSelectSearch(ctx *vmselectRequestCtx) error {
|
|||
return fmt.Errorf("cannot send empty error message: %w", err)
|
||||
}
|
||||
|
||||
count := 0
|
||||
// Send found blocks to vmselect.
|
||||
for ctx.sr.NextMetricBlock() {
|
||||
ctx.mb.MetricName = ctx.sr.MetricBlockRef.MetricName
|
||||
ctx.sr.MetricBlockRef.BlockRef.MustReadBlock(&ctx.mb.Block, fetchData)
|
||||
|
||||
vmselectMetricBlocksRead.Inc()
|
||||
vmselectMetricRowsRead.Add(ctx.mb.Block.RowsCount())
|
||||
rowsCount := ctx.mb.Block.RowsCount()
|
||||
vmselectMetricRowsRead.Add(rowsCount)
|
||||
count += rowsCount
|
||||
if count > *maxMetricsPointSearch {
|
||||
logger.Errorf("more than -search.maxMetricsPointSearch=%d point,discard more points", *maxMetricsPointSearch)
|
||||
break
|
||||
}
|
||||
|
||||
ctx.dataBuf = ctx.mb.Marshal(ctx.dataBuf[:0])
|
||||
if err := ctx.writeDataBufBytes(); err != nil {
|
||||
|
|
Loading…
Reference in a new issue