Skip to content

Activitylog service creates endless load on the backend after uploading #716

Closed

Description

@cscholz

For the past few days, I've been seeing similar entries in journalctl roughly every two seconds, like the following one:

2025-04-23T14:21:09+02:00 INF user idp:"none" opaque_id:"deaf1971-9364-4f3e-805a-2893fbc2cb3f" type:USER_TYPE_SERVICE authenticated line=[github.com/opencloud-eu/reva/[email protected]/internal/grpc/services/authprovider/authprovider.go:146](http://github.com/opencloud-eu/reva/[email protected]/internal/grpc/services/authprovider/authprovider.go:146) pkg=rgrpc service=auth-service traceid=c78fcdfee027f644912ea20fe5f493f7

For now I've not found an issue somewhere but unfortunately I'm also not able to interprete the log line record.

I would appreciate if someone can help me to understand what the log entries wanted to say.

Activity

  1. dragotin commented on Apr 24, 2025

    @dragotin
    Member

    renders the log output more or less useless

  2. rhafer commented on Apr 24, 2025

    @rhafer
    Member

    For now I've not found an issue somewhere but unfortunately I'm also not able to interprete the log line record.

    As mentioned in the matrix chat. I think we should not log stuff like this at the "INFO" level. It should at least be down to "DEBUG" or "TRACE".

    Regarding interpretation: The line basically just says that the service auth-service just successfully authenticated a service user (type:USER_TYPE_SERVICE). I guess you're more interested in finding out why that authentication happened and what the service user is actually doing there. For the you'd need to look at the surrounding log lines, maybe searching for lines having the same traceid.

  3. dragotin commented on Apr 24, 2025

    @dragotin
    Member

    In my case, these logs appeared after I copied some GB of data into my non collaborative PosixFS and started OpenCloud up again. From that point on there is one core constantly on 100% with opencloud. I wasn't able yet to pin down what it exactly does... The logfile is so flooded ;-)

  4. dragotin commented on Apr 24, 2025

    @dragotin
    Member

    Ah, yes, I let it run for a few days to give enough time (I hope) to assimilate all the files. But I have no clue if that has finished yet or not.

  5. cscholz commented on Apr 24, 2025

    @cscholz
    Author

    In my case, these logs appeared after I copied some GB of data into my non collaborative PosixFS and started OpenCloud up again. From that point on there is one core constantly on 100% with opencloud. I wasn't able yet to pin down what it exactly does... The logfile is so flooded ;-)

    I've copied also a bunch of data on filesystem level. ~ 200 GB. My host system was with 8 cores busy for hours.
    Also just waited and after 1-2 days the utilization was back to normal. I'm missing currently an option to see the indexing process of the files.

    Created a feature request to see the posix indexing status of opencloud: #718

  6. rhafer commented on Apr 24, 2025

    @rhafer
    Member

    I've copied also a bunch of data on filesystem level. ~ 200 GB. My host system was with 8 cores busy for hours.
    Also just waited and after 1-2 days the utilization was back to normal. I'm missing currently an option to see the indexing process of the files.

    I'd suggest to open a separate issue for this. It's unrelated to the auth-service's log entries.

  7. cscholz commented on Apr 24, 2025

    @cscholz
    Author

    For now I've not found an issue somewhere but unfortunately I'm also not able to interprete the log line record.

    As mentioned in the matrix chat. I think we should not log stuff like this at the "INFO" level. It should at least be down to "DEBUG" or "TRACE".

    Regarding interpretation: The line basically just says that the service auth-service just successfully authenticated a service user (type:USER_TYPE_SERVICE). I guess you're more interested in finding out why that authentication happened and what the service user is actually doing there. For the you'd need to look at the surrounding log lines, maybe searching for lines having the same traceid.

    Thanks for the explanation. As the message was in my log presented in read a thought it could be an issue.
    If it is just status message about a regular authentication than I agree that it should be visible on higher logging level

  8. dragotin commented on Apr 30, 2025

    @dragotin
    Member

    My home "server" still uses a lot of CPU with OpenCloud, even longer time after startup.
    This is the htop profile:

    Image

    I am considering that too much.

    The log file scrolls through with accesses as described above. This is the excerpt for a single traceid:

    2025-04-30T09:44:31Z DBG skipping auth line=github.com/opencloud-eu/reva/[email protected]/internal/grpc/interceptors/auth/auth.go:122 method=/cs3.gateway.v1beta1.GatewayAPI/Stat pkg=rgrpc service=gateway traceid=fd84166f1d106b094bd1e1ba2626ac89
    2025-04-30T09:44:31Z DBG unary code=OK end="30/Apr/2025:09:44:31 +0000" from=tcp://127.0.0.1:40506 line=github.com/opencloud-eu/reva/[email protected]/internal/grpc/interceptors/log/log.go:69 pkg=rgrpc service=gateway start="30/Apr/2025:09:44:31 +0000" time_ns=118439 traceid=fd84166f1d106b094bd1e1ba2626ac89 uri=/cs3.storage.registry.v1beta1.RegistryAPI/ListStorageProviders user-agent=grpc-go/1.72.0
    2025-04-30T09:44:31Z DBG unary code=OK end="30/Apr/2025:09:44:31 +0000" from=tcp://127.0.0.1:51976 line=github.com/opencloud-eu/reva/[email protected]/internal/grpc/interceptors/log/log.go:69 pkg=rgrpc service=storage-users start="30/Apr/2025:09:44:31 +0000" time_ns=570537 traceid=fd84166f1d106b094bd1e1ba2626ac89 uri=/cs3.storage.provider.v1beta1.ProviderAPI/Stat user-agent=grpc-go/1.72.0
    2025-04-30T09:44:31Z DBG unary code=OK end="30/Apr/2025:09:44:31 +0000" from=tcp://172.18.0.8:34454 line=github.com/opencloud-eu/reva/[email protected]/internal/grpc/interceptors/log/log.go:69 pkg=rgrpc service=gateway start="30/Apr/2025:09:44:31 +0000" time_ns=1729726 traceid=fd84166f1d106b094bd1e1ba2626ac89 uri=/cs3.gateway.v1beta1.GatewayAPI/Stat user-agent=grpc-go/1.72.0
    

    Since this still looks like "something" is stating files, I'll continue to wait - if it is still assimilating the files that I copied into the file system I would expect it looks similar.

  9. carlosjfcasero commented on Apr 30, 2025

    @carlosjfcasero

    I'm having same issue after copying a large amount of GB. Mentioned logs appears every1-2 secs and CPU usage is high for days

  10. dragotin commented on May 2, 2025

    @dragotin
    Member

    Yes. Same here after days. This makes OpenCloud not useable for me, and it wastes a lot of compute.

    Let's dig deeper. @aduffeck please help.

    I straced the opencloud process with strace -fp <pid> to understand what is causing the load. It seems that it tries to stat files that are not (longer) existing over and over again.

    The most files that are not existing on my machine, but tried to be stat'ed have the extension .lock or .blk such as:

    ...env/lib/python3.8/site-packages/pip/_vendor/html5lib/__pycache__/_tokenizer.cpython-38.pyc.lock
    ...opencloud/nats/jetstream/$G/streams/KV_activitylog/msgs/2689892.blk
    
  11. moved this from Qualification to Prio 2 in OpenCloud Team Boardon May 2, 2025
  12. added theissue type on May 2, 2025
  13. 8 remaining items

  14. rhafer commented on May 9, 2025

    @rhafer
    Member

    Hm, from the nats docs (https://docs.nats.io/nats-concepts/subjects#subject-usage-best-practices):

    Subject usage best practices

    There is no hard limit to subject size, but it is recommended to keep the maximum number of tokens in your subjects to a reasonable value. E.g. a maximum of 16 tokens and the subject length to less than 256 characters.

    I guess we'd be beyond the recommended 256 characters very quick. AFAICS we're already at 176 key length for a single resource id 😢

  15. rhafer commented on May 9, 2025

    @rhafer
    Member

    This is a pprof flame graph (for a 30sec interval) after copying 50000 1kB files manually into a space. File assimilation was already complete at this point. So you can see that the activitylog service is consuming roughly one half of the CPU time (and about a half of that is spent on JSON marshalling and unmarshalling). The rest of the CPU is spent mainly in the NATS server (not sure what it is doing there but Sprintf shows up there pretty promiently) and in the garbage collector (sigh)

    Image

    This goes on for hours(!). Though I assume this is again because NATS starts to resend un-acked messages on the activitylog.

  16. rhafer commented on May 9, 2025

    @rhafer
    Member

    We could e.g. store each Event in a separate value using a different "subject" as the Key. The key would then be resourceid.eventid.

    I did a small experiment in that direction: https://github.com/rhafer/opencloud/tree/issue/716
    and now the graph looks like this:

    Image

    So now the activitylog consumes just the tiny bit that is highlighted in that screenshot. And it was able to work of the event queue pretty quickly.

  17. rhafer commented on May 9, 2025

    @rhafer
    Member

    The rest of the CPU is spent mainly in the NATS server (not sure what it is doing there but Sprintf shows up there pretty promiently)

    Hm, this is because we enable trace logs for the nats server by default (https://github.com/opencloud-eu/opencloud/blob/main/services/nats/pkg/server/nats/nats.go#L35) 🤯

  18. aduffeck commented on May 12, 2025

    @aduffeck
    Member

    But I somehow think there must also be a better way to store the Activities than what we currently do.

    Hm, thinking about this further might it be possible to just store a single Event instead of storing it several time (once per parent resource). If we'd just use <spaceid>.<parentresourceid>.<parentresourceid>.<....>.<resourceid> as the key?

    To get all activities for a specific level of the filetree would be just a matter of doing a kv.Watch() on the <spaceid>.<parentresourceid>.* subject. Queries like *.<resourceid>.* should also work. 🤔

    That sounds attractive but has the problem that you'd have to rewrite lots of keys when a directory gets renamed.
    I'm not sure if the added complexity is worth the effort.

  19. aduffeck commented on May 12, 2025

    @aduffeck
    Member

    I did a small experiment in that direction: https://github.com/rhafer/opencloud/tree/issue/716 and now the graph looks like this:

    So now the activitylog consumes just the tiny bit that is highlighted in that screenshot. And it was able to work of the event queue pretty quickly.

    Did you also try to implement the reading part or was it just about benchmarking the writes? Hm, and I wonder how expensive it gets to maintain the limit of activities per resource.

    I had two other ideas besides buffering the writes (which already gets rid of most of the load):

    1. Use messagepack arrays instead of json, which is considerably faster when marshalling and unmarshalling and doesn't really have any downside in this context as far as I can tell.
    2. Use some kind of write-ahead log to collect a bunch of events in a smaller array before writing it to the "main" array. We'd lose precision with the event limit however and reading the activities would take two reads instead of one.
  20. rhafer commented on May 12, 2025

    @rhafer
    Member

    I did a small experiment in that direction: https://github.com/rhafer/opencloud/tree/issue/716 and now the graph looks like this:
    So now the activitylog consumes just the tiny bit that is highlighted in that screenshot. And it was able to work of the event queue pretty quickly.

    Did you also try to implement the reading part or was it just about benchmarking the writes? Hm, and I wonder how expensive it gets to maintain the limit of activities per resource.

    This was just the writing part. Reading does require some more work. We would need to add Watch() support to the natkv go-mirco driver. Regarding the limit: The current limit of 6000 events per ResourceID was introduced because the values are too large. The suggested approach wouldn't have that issue. I guess we could just use some time based expiry.

    I had two other ideas besides buffering the writes (which already gets rid of most of the load):

    1. Use messagepack arrays instead of json, which is considerably faster when marshalling and unmarshalling and doesn't really have any downside in this context as far as I can tell.
    
    2. Use some kind of write-ahead log to collect a bunch of events in a smaller array before writing it to the "main" array. We'd lose precision with the event limit however and reading the activities would take two reads instead of one.
    

    Btw, @butonic also commented, that the current implementation looses events as soon as more than a single activitylog instance in running.

  21. changed the title [-]2 journalctl log entries per second start with [user idp:"none" ...][/-] [+]Activitylog service creates endless load on the backend after uploading[/+] on May 12, 2025
  22. fschade commented on May 12, 2025

    @fschade
    Member

    I ran a few tests to see how it works with and without activity log and if there are any significant differences.
    Result: no performance improvement without the activitylog service, the http_req_duration is a tiny bit shorter, but I would rather put that in the test deviation drawer

    activitylog enabled

             /\      Grafana   /‾‾/  
        /\  /  \     |\  __   /  /   
       /  \/    \    | |/ /  /   ‾‾\ 
      /          \   |   (  |  (‾)  |
     / __________ \  |_|\_\  \_____/ 
    
         execution: local
            script: packages/k6-tests/artifacts/koko-platform-040-create-upload-rename-delete-folder-and-file-ramping-k6.js
            output: -
    
         scenarios: (100.00%) 1 scenario, 25 max VUs, 25m30s max duration (incl. graceful stop):
                  * create_upload_rename_delete_folder_and_file_040: Up to 25 looping VUs for 25m0s over 3 stages (gracefulRampDown: 30s, exec: create_upload_rename_delete_folder_and_file_040, gracefulStop: 30s)
    
    
         ✓ authn -> logonResponse - status
         ✓ authn -> authorizeResponse - status
         ✓ authn -> accessTokenResponse - status
         ✓ client -> role.getMyDrives - status
         ✓ client -> resource.createResource - status
         ✓ client -> resource.uploadResource - status
         ✓ client -> resource.moveResource - status
         ✓ client -> resource.deleteResource - status
    
         checks.........................: 100.00% 2297 out of 2297
         data_received..................: 2.9 MB  1.9 kB/s
         data_sent......................: 8.1 GB  5.3 MB/s
         http_req_blocked...............: avg=32.01µs min=1µs    med=4µs     max=4.34ms   p(90)=10µs    p(95)=12µs    
         http_req_connecting............: avg=3.19µs  min=0s     med=0s      max=644µs    p(90)=0s      p(95)=0s      
         http_req_duration..............: avg=48.07ms min=5.24ms med=28.37ms max=508.4ms  p(90)=75.23ms p(95)=153.61ms
           { expected_response:true }...: avg=48.07ms min=5.24ms med=28.37ms max=508.4ms  p(90)=75.23ms p(95)=153.61ms
         http_req_failed................: 0.00%   0 out of 2297
         http_req_receiving.............: avg=51.6µs  min=19µs   med=46µs    max=466µs    p(90)=69µs    p(95)=88.19µs 
         http_req_sending...............: avg=5.33ms  min=7µs    med=18µs    max=213.01ms p(90)=1.33ms  p(95)=44.31ms 
         http_req_tls_handshaking.......: avg=21.58µs min=0s     med=0s      max=3.7ms    p(90)=0s      p(95)=0s      
         http_req_waiting...............: avg=42.69ms min=5.19ms med=28.31ms max=334.27ms p(90)=73.76ms p(95)=110.3ms 
         http_reqs......................: 2297    1.501317/s
         iteration_duration.............: avg=1m3s    min=1m3s   med=1m3s    max=1m4s     p(90)=1m3s    p(95)=1m4s    
         iterations.....................: 473     0.309152/s
         vus............................: 1       min=0            max=25
         vus_max........................: 25      min=25           max=25
    
    
    running (25m30.0s), 00/25 VUs, 473 complete and 14 interrupted iterations
    create_upload_rename_delete... ✓ [======================================] 00/25 VUs  25m0s

    activitylog disabled

             /\      Grafana   /‾‾/  
        /\  /  \     |\  __   /  /   
       /  \/    \    | |/ /  /   ‾‾\ 
      /          \   |   (  |  (‾)  |
     / __________ \  |_|\_\  \_____/ 
    
         execution: local
            script: packages/k6-tests/artifacts/koko-platform-040-create-upload-rename-delete-folder-and-file-ramping-k6.js
            output: -
    
         scenarios: (100.00%) 1 scenario, 25 max VUs, 25m30s max duration (incl. graceful stop):
                  * create_upload_rename_delete_folder_and_file_040: Up to 25 looping VUs for 25m0s over 3 stages (gracefulRampDown: 30s, exec: create_upload_rename_delete_folder_and_file_040, gracefulStop: 30s)
    
    
         ✓ authn -> logonResponse - status
         ✓ authn -> authorizeResponse - status
         ✓ authn -> accessTokenResponse - status
         ✓ client -> role.getMyDrives - status
         ✓ client -> resource.createResource - status
         ✓ client -> resource.uploadResource - status
         ✓ client -> resource.moveResource - status
         ✓ client -> resource.deleteResource - status
    
         checks.........................: 100.00% 2297 out of 2297
         data_received..................: 2.9 MB  1.9 kB/s
         data_sent......................: 8.1 GB  5.3 MB/s
         http_req_blocked...............: avg=31.61µs min=1µs    med=4µs     max=5.67ms   p(90)=10µs    p(95)=11µs    
         http_req_connecting............: avg=3.36µs  min=0s     med=0s      max=1.51ms   p(90)=0s      p(95)=0s      
         http_req_duration..............: avg=47.95ms min=6.04ms med=28.49ms max=483.33ms p(90)=75.96ms p(95)=149.3ms 
           { expected_response:true }...: avg=47.95ms min=6.04ms med=28.49ms max=483.33ms p(90)=75.96ms p(95)=149.3ms 
         http_req_failed................: 0.00%   0 out of 2297
         http_req_receiving.............: avg=51.27µs min=17µs   med=46µs    max=337µs    p(90)=68µs    p(95)=83µs    
         http_req_sending...............: avg=5.4ms   min=6µs    med=19µs    max=213.44ms p(90)=1.27ms  p(95)=43.38ms 
         http_req_tls_handshaking.......: avg=21.2µs  min=0s     med=0s      max=5.34ms   p(90)=0s      p(95)=0s      
         http_req_waiting...............: avg=42.5ms  min=5.98ms med=28.39ms max=342.08ms p(90)=74.47ms p(95)=107.81ms
         http_reqs......................: 2297    1.501307/s
         iteration_duration.............: avg=1m3s    min=1m3s   med=1m3s    max=1m4s     p(90)=1m3s    p(95)=1m4s    
         iterations.....................: 473     0.30915/s
         vus............................: 1       min=0            max=25
         vus_max........................: 25      min=25           max=25
    
    
    running (25m30.0s), 00/25 VUs, 473 complete and 14 interrupted iterations
    create_upload_rename_delete... ✓ [======================================] 00/25 VUs  25m0s
  23. moved this from Prio 2 to In Progress in OpenCloud Team Boardon May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions