Skip to content

Commit

Permalink
Merge pull request #3689 from quite4work/add-read-write-timeout-optio…
Browse files Browse the repository at this point in the history
…ns-for-parca-server

pkg/parca: Add --http-read-timeout and --http-write-timeout options
  • Loading branch information
brancz authored Aug 31, 2023
2 parents 86e4f37 + cc57b85 commit c306fcd
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 64 deletions.
120 changes: 63 additions & 57 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,81 +82,87 @@ Flags:
Usage: parca
Flags:
-h, --help Show context-sensitive help.
-h, --help Show context-sensitive help.
--config-path="parca.yaml"
Path to config file.
--mode="all" Scraper only runs a scraper that sends to a
remote gRPC endpoint. All runs all components.
--http-address=":7070" Address to bind HTTP server to.
--port="" (DEPRECATED) Use http-address instead.
--log-level="info" Log level.
--log-format="logfmt" Configure if structured logging as JSON or as
logfmt
--otlp-address=STRING The endpoint to send OTLP traces to.
--otlp-exporter="grpc" The OTLP exporter to use.
Path to config file.
--mode="all" Scraper only runs a scraper that sends to a
remote gRPC endpoint. All runs all components.
--http-address=":7070" Address to bind HTTP server to.
--http-read-timeout=5s Timeout duration for HTTP server to read
request body.
--http-write-timeout=1m Timeout duration for HTTP server to write
response body.
--port="" (DEPRECATED) Use http-address instead.
--log-level="info" Log level.
--log-format="logfmt" Configure if structured logging as JSON or as
logfmt
--otlp-address=STRING The endpoint to send OTLP traces to.
--otlp-exporter="grpc" The OTLP exporter to use.
--cors-allowed-origins=CORS-ALLOWED-ORIGINS,...
Allowed CORS origins.
--version Show application version.
--path-prefix="" Path prefix for the UI
Allowed CORS origins.
--version Show application version.
--path-prefix="" Path prefix for the UI
--mutex-profile-fraction=0
Fraction of mutex profile samples to collect.
--block-profile-rate=0 Sample rate for block profile.
--enable-persistence Turn on persistent storage for the metastore and
profile storage.
Fraction of mutex profile samples to collect.
--block-profile-rate=0 Sample rate for block profile.
--enable-persistence Turn on persistent storage for the metastore
and profile storage.
--storage-granule-size=26265625
Granule size in bytes for storage.
Granule size in bytes for storage.
--storage-active-memory=536870912
Amount of memory to use for active storage.
Defaults to 512MB.
--storage-path="data" Path to storage directory.
--storage-enable-wal Enables write ahead log for profile storage.
Amount of memory to use for active storage.
Defaults to 512MB.
--storage-path="data" Path to storage directory.
--storage-enable-wal Enables write ahead log for profile storage.
--storage-snapshot-trigger-size=134217728
Number of bytes to trigger a snapshot. Defaults
to 1/4 of active memory. This is only used if
enable-wal is set.
Number of bytes to trigger a snapshot. Defaults
to 1/4 of active memory. This is only used if
enable-wal is set.
--storage-row-group-size=8192
Number of rows in each row group during
compaction and persistence. Setting to <= 0
results in a single row group per file.
Number of rows in each row group during
compaction and persistence. Setting to <= 0
results in a single row group per file.
--symbolizer-demangle-mode="simple"
Mode to demangle C++ symbols. Default mode
is simplified: no parameters, no templates,
no return type
Mode to demangle C++ symbols. Default mode
is simplified: no parameters, no templates,
no return type
--symbolizer-number-of-tries=3
Number of tries to attempt to symbolize an
unsybolized location
Number of tries to attempt to symbolize an
unsybolized location
--debuginfo-cache-dir="/tmp"
Path to directory where debuginfo is cached.
Path to directory where debuginfo is cached.
--debuginfo-upload-max-size=1000000000
Maximum size of debuginfo upload in bytes.
Maximum size of debuginfo upload in bytes.
--debuginfo-upload-max-duration=15m
Maximum duration of debuginfo upload.
Maximum duration of debuginfo upload.
--debuginfo-uploads-signed-url
Whether to use signed URLs for debuginfo
uploads.
Whether to use signed URLs for debuginfo
uploads.
--debuginfod-upstream-servers=debuginfod.elfutils.org,...
Upstream debuginfod servers. Defaults to
debuginfod.elfutils.org. It is an ordered
list of servers to try. Learn more at
https://sourceware.org/elfutils/Debuginfod.html
Upstream debuginfod servers. Defaults to
debuginfod.elfutils.org. It is an ordered
list of servers to try. Learn more at
https://sourceware.org/elfutils/Debuginfod.html
--debuginfod-http-request-timeout=5m
Timeout duration for HTTP request to upstream
debuginfod server. Defaults to 5m
--metastore="badger" Which metastore implementation to use
Timeout duration for HTTP request to upstream
debuginfod server. Defaults to 5m
--metastore="badger" Which metastore implementation to use
--profile-share-server="api.pprof.me:443"
gRPC address to send share profile requests to.
--store-address=STRING gRPC address to send profiles and symbols to.
--bearer-token=STRING Bearer token to authenticate with store.
gRPC address to send share profile requests to.
--store-address=STRING gRPC address to send profiles and symbols to.
--bearer-token=STRING Bearer token to authenticate with store.
--bearer-token-file=STRING
File to read bearer token from to authenticate
with store.
--insecure Send gRPC requests via plaintext instead of TLS.
--insecure-skip-verify Skip TLS certificate verification.
File to read bearer token from to authenticate
with store.
--insecure Send gRPC requests via plaintext instead of
TLS.
--insecure-skip-verify Skip TLS certificate verification.
--external-label=KEY=VALUE;...
Label(s) to attach to all profiles in
scraper-only mode.
--experimental-arrow EXPERIMENTAL: Enables Arrow ingestion, this will
reduce CPU usage but will increase memory usage.
Label(s) to attach to all profiles in
scraper-only mode.
--experimental-arrow EXPERIMENTAL: Enables Arrow ingestion, this
will reduce CPU usage but will increase memory
usage.
```
<!-- prettier-ignore-end -->

Expand Down
14 changes: 10 additions & 4 deletions pkg/parca/parca.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,12 @@ const (
)

type Flags struct {
ConfigPath string `default:"parca.yaml" help:"Path to config file."`
Mode string `default:"all" enum:"all,scraper-only" help:"Scraper only runs a scraper that sends to a remote gRPC endpoint. All runs all components."`
HTTPAddress string `default:":7070" help:"Address to bind HTTP server to."`
Port string `default:"" help:"(DEPRECATED) Use http-address instead."`
ConfigPath string `default:"parca.yaml" help:"Path to config file."`
Mode string `default:"all" enum:"all,scraper-only" help:"Scraper only runs a scraper that sends to a remote gRPC endpoint. All runs all components."`
HTTPAddress string `default:":7070" help:"Address to bind HTTP server to."`
HTTPReadTimeout time.Duration `default:"5s" help:"Timeout duration for HTTP server to read request body."`
HTTPWriteTimeout time.Duration `default:"1m" help:"Timeout duration for HTTP server to write response body."`
Port string `default:"" help:"(DEPRECATED) Use http-address instead."`

Logs FlagsLogs `embed:"" prefix:"log-"`
OTLP FlagsOTLP `embed:"" prefix:"otlp-"`
Expand Down Expand Up @@ -566,6 +568,8 @@ func Run(ctx context.Context, logger log.Logger, reg *prometheus.Registry, flags
ctx,
logger,
flags.HTTPAddress,
flags.HTTPReadTimeout,
flags.HTTPWriteTimeout,
flags.CORSAllowedOrigins,
flags.PathPrefix,
server.RegisterableFunc(func(ctx context.Context, srv *grpc.Server, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error {
Expand Down Expand Up @@ -778,6 +782,8 @@ func runScraper(
serveCtx,
logger,
flags.HTTPAddress,
flags.HTTPReadTimeout,
flags.HTTPWriteTimeout,
flags.CORSAllowedOrigins,
flags.PathPrefix,
server.RegisterableFunc(func(ctx context.Context, srv *grpc.Server, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) error {
Expand Down
15 changes: 12 additions & 3 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,16 @@ func NewServer(reg *prometheus.Registry, version string) *Server {
}

// ListenAndServe starts the http grpc gateway server.
func (s *Server) ListenAndServe(ctx context.Context, logger log.Logger, addr string, allowedCORSOrigins []string, pathPrefix string, registerables ...Registerable) error {
func (s *Server) ListenAndServe(
ctx context.Context,
logger log.Logger,
addr string,
readTimeout time.Duration,
writeTimeout time.Duration,
allowedCORSOrigins []string,
pathPrefix string,
registerables ...Registerable,
) error {
level.Info(logger).Log("msg", "starting server", "addr", addr)

logOpts := []grpc_logging.Option{
Expand Down Expand Up @@ -160,8 +169,8 @@ func (s *Server) ListenAndServe(ctx context.Context, logger log.Logger, addr str
fallbackNotFound(internalMux, uiHandler),
allowedCORSOrigins,
),
ReadTimeout: 5 * time.Second, // TODO make config option
WriteTimeout: time.Minute, // TODO make config option
ReadTimeout: readTimeout,
WriteTimeout: writeTimeout,
}

met.InitializeMetrics(srv)
Expand Down

0 comments on commit c306fcd

Please sign in to comment.