Skip to content

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

@vartagg

Description

@vartagg

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions