Skip to content

Memory leak when connecting to the LD relay proxy #416

@harshit98

Description

@harshit98

Is this a support request?
Yes

Describe the bug
When I connect my python service to LD relay proxy service - during pod starts few of the pods gets aggresively high memory utilisation reaching close to 100% and some other remaining pods face continuous increase in memory. The memory utilisation doesn't work in bounded manner. Without relay proxy, memory work fine.

To reproduce
Python code to connect relay proxy (using LD SDK Server pkg 7.4.1) and Python 3.10

def launch_darkly_setup():
    config_kwargs = dict(
        offline=Config.LAUNCHDARKLY_OFFLINE, sdk_key=Config.LAUNCHDARKLY_SDK_KEY
    )
    
    if Config.LAUNCHDARKLY_RELAY_ENABLED and Config.LAUNCHDARKLY_RELAY_URL:
        logging.info("LaunchDarkly Relay Proxy enabled, using relay at %s", Config.LAUNCHDARKLY_RELAY_URL)
        config_kwargs.update(
            stream_uri=Config.LAUNCHDARKLY_RELAY_URL,
            base_uri=Config.LAUNCHDARKLY_RELAY_URL,
            events_uri=Config.LAUNCHDARKLY_RELAY_URL,
            send_events=False,
        )
    else:
        logging.info("LaunchDarkly Relay Proxy disabled, connecting directly to LaunchDarkly")

    ldclient.set_config(ldclient.Config(**config_kwargs))

    # Wait for LaunchDarkly client to initialize (especially important for relay)
    client = ldclient.get()
    if not client.is_initialized():
        logger.info("Waiting for LaunchDarkly client to initialize...")
        client.wait_for_initialization(timeout=10)
        if client.is_initialized():
            logger.info("LaunchDarkly client initialized successfully")
        else:
            logger.warning("LaunchDarkly client initialization timeout - proceeding with defaults")
    else:
        logger.info("LaunchDarkly client already initialized")

Expected behavior
Service memory leak should not happen when connect LD client via relay proxy.

Logs
N/A

SDK version
7.6.1

Language version, developer tools
Python 3.10

OS/platform
N/A

Additional context
Profiler screenshots

Image Image Image

Pod resources:

resources:
    limits:
        cpu: 1200m
        memory: 2Gi
    requests:
         cpu: 400m
         memory: 400Mi

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions