civic-eagle / statsd-http-proxy

StatsD HTTP proxy server with REST interface for using in browsers
MIT License
0 stars 0 forks source link

Switch to async processing/writing of metrics #6

Closed johnseekins closed 2 years ago

johnseekins commented 2 years ago

https://github.com/civic-eagle/statsd-http-proxy/issues/5

This should speed up individual http requests, which will make clients happier.

johnseekins commented 2 years ago

Rough testing of speed improvements:

with channel:
  http_request_time_secs_total_sum{method="POST",path="/count",status_code="0"} 0.00023863
without channel:
  http_request_time_secs_total_sum{method="POST",path="/count",status_code="0"} 0.000417342
johnseekins commented 2 years ago

There is currently a small chance of lost data on shutdown. We'd need to add a waitgroup/context to watch for during shutdown. We do at least close the channel on sigint/sigterm to the http server, so the window of potentially lost requests is fairly small (if we can't process our backlog in 5 seconds, we lose data).