jjneely / statsrelay

A Golang consistent hashing proxy for statsd
MIT License
56 stars 19 forks source link

Add exponential backoff with retries for TCP dial #21

Closed szibis closed 7 years ago

szibis commented 7 years ago

Example output:

2017/04/21 15:41:10 Starting version 0.0.6
2017/04/21 15:41:10 Listening on 127.0.0.1:8125
2017/04/21 15:41:10 Setting socket read buffer size to: 1600
2017/04/21 15:41:10 TCP send timeout set to 500ms
2017/04/21 15:41:10 TCP Backoff set Min: 50ms Max: 1s Factor: 1.500000 Retries: 10
2017/04/21 15:41:10 Metrics tags set to cluster:dev1,env:sandbox,region:us-east-1,project:default,instance:ip-10-10-10-10,nameapp:hello-world,statsd:true
2017/04/21 15:41:10 Rock and Roll!
2017/04/21 15:41:15 Sending jetty.handler.put-requests.1MinuteRate:0|g|#cluster:dev1,env:sandbox,region:us-east-1,project:default,instance:ip-10-10-10-10,nameapp:hello-world,statsd:true to 127.0.0.1:9125
2017/04/21 15:41:15 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 50ms, retries left 10/10]
2017/04/21 15:41:15 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 75ms, retries left 9/10]
2017/04/21 15:41:15 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 112.5ms, retries left 8/10]
2017/04/21 15:41:15 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 168.75ms, retries left 7/10]
2017/04/21 15:41:16 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 253.125ms, retries left 6/10]
2017/04/21 15:41:16 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 379.6875ms, retries left 5/10]
2017/04/21 15:41:16 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 569.53125ms, retries left 4/10]
2017/04/21 15:41:17 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 854.296875ms, retries left 3/10]
2017/04/21 15:41:18 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 1s, retries left 2/10]
2017/04/21 15:41:19 TCP error for 127.0.0.1:9125 - dial tcp 127.0.0.1:9125: getsockopt: connection refused [Reconnecting in 1s, retries left 1/10]
2017/04/21 15:41:20 Processed 1 metrics. Running total: 1. Metrics/sec: 0
jjneely commented 7 years ago

Thanks!