Skip to content
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

set SO_LINGER=0 to TCP connection #1266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Sniper91
Copy link

Closing TCP socket after every probe may cause large numbers of connections sitting in the TIME_WAIT state
Relevant Issue: #794

set SO_LINGER=0 to avoid problem above
Reference: https://stackoverflow.com/questions/3757289/when-is-tcp-option-so-linger-0-required

@mem
Copy link
Contributor

mem commented Jul 23, 2024

I tried to reproduce the situation reported in the issue and I couldn't. I don't see connections in the TIME_WAIT state. Would it be possible for you to provide more details as to how to reproduce this?

I'm hesitant to simply reset TCP connections from the client side instead of closing them in an orderly fashion.

@Sniper91
Copy link
Author

  1. run blackbox_exporter with file blackbox.yml
    version=0.25.0, branch=HEAD, revision=ef3ff4fef195333fb8ee0039fb487b2f5007908f
docker run -d  --rm   -p 9115:9115   --name blackbox_exporter   -v $(pwd):/config   quay.io/prometheus/blackbox-exporter:latest --config.file=/config/blackbox.yml
  1. run prometheus
docker run -d --network host --rm --name prometheus   -v $(pwd)/prometheus.yml:/etc/prometheus/prometheus.yml prom/prometheus

configuration file:

global:
  scrape_interval: 5s
scrape_configs:
  - job_name: 'blackbox'
    metrics_path: /probe
    params:
      module: [http_2xx] 
    static_configs:
      - targets:
          - https://prometheus.io
    relabel_configs:
      - source_labels: [__address__]
        target_label: __param_target
      - source_labels: [__param_target]
        target_label: instance
      - target_label: __address__
        replacement: 127.0.0.1:9115
  1. wait several minutes, check tcp connection state of blackbox_exporter container
  docker exec blackbox_exporter netstat -tnp
netstat

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants