#I have seen memory leak in sentry-web. How do we control its memory usage

4 messages · Page 1 of 1 (latest)

flat rune
#

memory usage on pods keeps increasing, until we restart pods.

idle yachtBOT
#

Hi @flat rune. I'm happy to dig into this for you! I'll check my internal sources for answers to your question! :wave:

#

If you're experiencing memory leaks or high memory usage in the Sentry web service (sentry-web), especially in self-hosted environments, there are a few steps and workarounds reported by the community that may help control memory usage:

  1. Set ulimits for the web container
    Adding ulimits to your Docker Compose configuration for the web service has been shown to help control memory usage and prevent runaway resource consumption. For example, you can add the following to your docker-compose.yml under the web service:

    web:
      ...
      ulimits:
        nofile:
          soft: 4096
          hard: 4096
    

    Users have reported that this change stabilized memory usage and resolved the issue of the web container consuming excessive RAM over time. This fix has been merged into the official self-hosted repository as well.
    See details and confirmation from users and resolution in the self-hosted repo.

  2. Monitor for underlying issues
    In some cases, high memory usage was linked to the underlying OS or Docker environment (e.g., RHEL/Rocky Linux vs. Debian). If you continue to see issues after applying the ulimits fix, consider testing on a different OS or Docker version to rule out environment-specific problems
    Discussion of OS-related issues.

  3. Profile memory usage
    If the problem persists, Sentry maintainers have recommended attaching a memory profiler (such as memray) to the web process to identify the source of the leak. This can help pinpoint whether the issue is with Sentry itself or with the environment
    Profiling suggestion.

#
  1. Upgrade to the latest version
    Ensure you are running the latest version of Sentry self-hosted, as memory management improvements and bug fixes are released regularly.

Summary:
The most effective and confirmed solution is to set ulimits for the web container in your Docker Compose configuration. If memory usage still grows uncontrollably, consider profiling the process and reviewing your OS/Docker environment for compatibility issues.

If you need more detailed guidance on profiling or further troubleshooting, please provide more information about your setup and Sentry version.

Note: you can ask me a follow up question by @ mentioning me again :speech_balloon: