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

monitor(app).start_server() runs server which must not be using in production - having memory leaks issues #32

Open
vartagg opened this issue Apr 26, 2020 · 0 comments

Comments

@vartagg
Copy link

vartagg commented Apr 26, 2020

I found that this way of prometheus metrics server starting, which code is

class _ThreadingSimpleServer(ThreadingMixIn, HTTPServer):
    """Thread per request HTTP server."""
def start_http_server(port, addr='', registry=REGISTRY):
    """Starts an HTTP server for prometheus metrics as a daemon thread"""
    CustomMetricsHandler = MetricsHandler.factory(registry)
    httpd = _ThreadingSimpleServer((addr, port), CustomMetricsHandler)
    t = threading.Thread(target=httpd.serve_forever)
    t.daemon = True
    t.start()

is starting the server, which has memory leaks. I found it by profiling app with tracemalloc library. This server is infinitely opening new threads. I think this behavior must be specified in the docs.

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

No branches or pull requests

1 participant