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

Potential memory leak #423

Closed
armin-malek opened this issue Feb 12, 2024 · 11 comments
Closed

Potential memory leak #423

armin-malek opened this issue Feb 12, 2024 · 11 comments
Assignees
Labels
bug Something isn't working no-issue-activity

Comments

@armin-malek
Copy link

after startup, it slowly starts using more memory, in a few hours it reaches over 1GB
because it works just fine with much less memory usage at startup, I think it's caused by a memory leak

To Reproduce
here is the config file I'm using my provider is Idrive e2

# Log configuration
log:
  # Log level
  level: info
  # Log format
  format: text
  # Log file path
  # filePath:

#Server configurations
server:
  listenAddr: ""
  port: 8080

# Targets map
targets:
  first-bucket:
    ## Mount point
    mount:
      path:
        - /mybucket/
    # ## Actions
    actions:
      # Action for GET requests on target
      GET:
        # Will allow GET requests
        enabled: true
        # Configuration for GET requests
        config:
          # Redirect with trailing slash when a file isn't found
          redirectWithTrailingSlashForNotFoundFile: true
          # Index document to display if exists in folder
          indexDocument: index.html
          # Allow to add headers to streamed files (can be templated)
          streamedFileHeaders: {}
          # Redirect to a S3 signed URL
          redirectToSignedUrl: false
          # Signed URL expiration time
          signedUrlExpiration: 15m
          # Disable listing
          # Note: This will return an empty list or you should change the folder list template (in general or in this target)
          disableListing: true
          # Webhooks
          webhooks: []
      # Action for PUT requests on target
      PUT:
        # Will allow PUT requests
        enabled: false
        # Configuration for PUT requests
        config:
          # Metadata key/values that will be put on S3 objects.
          # Values can be templated. Empty values will be flushed.
          metadata:
            key: value
          # System Metadata cases.
          # Values can be templated. Empty values will be flushed.
          systemMetadata:
            # Cache-Control value (will be put as header after)
            cacheControl: ""
            # Content-Disposition value (will be put as header after)
            contentDisposition: ""
            # Content-Encoding value (will be put as header after)
            contentEncoding: ""
            # Content-Language value (will be put as header after)
            contentLanguage: ""
            # Expires value (will be put as header after)
            # Side note: This must have the RFC3339 date format at the end.
            expires: ""
          # Storage class that will be used for uploaded objects
          # See storage class here: https://docs.aws.amazon.com/AmazonS3/latest/dev/storage-class-intro.html
          # Values can be templated. Empty values will be flushed.
          storageClass: STANDARD # GLACIER, ...
          # Will allow override objects if enabled
          allowOverride: false
          # Canned ACL put on each file uploaded.
          # https://docs.aws.amazon.com/AmazonS3/latest/userguide/acl-overview.html#canned-acl
          # cannedACL: ""
          # Webhooks
          webhooks: []
      # Action for DELETE requests on target
      DELETE:
        # Will allow DELETE requests
        enabled: false
        # Configuration for DELETE requests
        config:
          # Webhooks
          webhooks: []
   
    ## Bucket configuration
    bucket:
      name: mybucket
      prefix:
      region: eu-west-1
      s3Endpoint: "idrive-e2.com"
      disableSSL: false
      credentials:
        accessKey:
          env: S3_ACCESS
        secretKey:
          env: S3_KEY

Expected behavior
less and stable ram usage

Version and platform (please complete the following information):

  • Platform: Linux
  • Arch: amd64
  • Version: 4.12 (should be latest)
@armin-malek armin-malek added the bug Something isn't working label Feb 12, 2024
@oxyno-zeta
Copy link
Owner

Hello @armin-malek ,

Thanks for your issue.

I never used this provider so I can't say if it is coming from this or not.
But I have other ideas in mind. Can you answer those questions please ?:

  • Do you have a lot of requests on your server ?
  • Do you have a lot of different path on your requests ? (/mybucket/file1, file2, file3, ...)

Regards,

@oxyno-zeta oxyno-zeta self-assigned this Feb 12, 2024
@armin-malek
Copy link
Author

we have close to 8 million files in the bucket
and we serve around 7 objects per second (in reality it's a burst of 30 to 40 objects every few seconds),
the average object size is around 70KB

@oxyno-zeta
Copy link
Owner

I think I have an idea of why.

People requesting different files all the time ? Or are they the same for multiple minutes ?

@armin-malek
Copy link
Author

it's like an image hosting platform so yeah it should be mostly random objects

@oxyno-zeta
Copy link
Owner

Ok so I think I know why. This must come from prometheus metrics which are saving metrics per "request path". This can be patched for sure.

@armin-malek
Copy link
Author

Ok so I think I know why. This must come from prometheus metrics which are saving metrics per "request path". This can be patched for sure.

I'm not familiar with the code base but maybe an option to disable the metrics in the config file should do the trick
for now, i'll keep restarting the container every once in a while :)

oxyno-zeta added a commit that referenced this issue Feb 15, 2024
@oxyno-zeta
Copy link
Owner

I've just released a new version. The 4.13.0 release have a configuration dedicated for this.

Here is an example:

# Metrics configuration
metrics:
  # Disable router path save in HTTP metrics
  disableRouterPath: true

That should fix your problem.

PS: Out of this, do you use s3-proxy to make a tile map server ?

@armin-malek
Copy link
Author

thanks, it has solved the problem!

PS: Out of this, do you use s3-proxy to make a tile map server ?
no it is just serving images from a private bucket for a machine learning project

@armin-malek
Copy link
Author

armin-malek commented Feb 17, 2024

out of this too
currently it's logging every request to stdout, is there way to disable that too? i couldn't find it in the docs
if i'm not mistaken writing to stdout is not exactly cheap
what other log levels we have in the config file?

@oxyno-zeta
Copy link
Owner

Cool to hear this ! That's great!

Yes that's a feature to log everything. You can change the log level to error if you want only errors. All log levels from uber/zap logger are supported.

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 10 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working no-issue-activity
Projects
None yet
Development

No branches or pull requests

2 participants