mdouchement / standardfile

Yet Another Standardfile (standardnotes server) Implementation written in Golang
MIT License
80 stars 9 forks source link

Continuous network requests with idle clients (since v0.6.6) #96

Closed vszakats closed 1 year ago

vszakats commented 1 year ago

I tried a fresh v0.10.0 install today on a Raspberry. Things went well and the latest official macOS and iOS clients seem to work as expected.

But, while any of the clients are open, even when sitting idle, I noticed that the server is continously handling requests, many times a second:

[...]
[200] POST /v1/items (313) 2.28679ms
[200] POST /v1/items (313) 3.001393ms
[200] POST /v1/items (313) 2.505491ms
[200] POST /v1/items (313) 4.199917ms
[200] POST /v1/items (313) 2.634193ms
[200] POST /v1/items (313) 2.369752ms
[200] POST /v1/items (313) 2.479732ms
[200] POST /v1/items (313) 2.474639ms
[200] POST /v1/items (313) 2.477399ms
[200] POST /v1/items (313) 3.468239ms
[200] POST /v1/items (313) 3.779013ms
[200] POST /v1/items (313) 2.581231ms
[200] POST /v1/items (313) 2.841747ms
[200] POST /v1/items (313) 2.532047ms
[200] POST /v1/items (313) 2.870042ms
[200] POST /v1/items (313) 2.769191ms
[200] POST /v1/items (313) 2.668656ms
[200] POST /v1/items (313) 3.201558ms
[200] POST /v1/items (313) 2.557176ms
[200] POST /v1/items (313) 2.33653ms
[200] POST /v1/items (313) 5.08261ms
[200] POST /v1/items (313) 6.139988ms
[200] POST /v1/items (313) 2.498935ms
[200] POST /v1/items (313) 2.268641ms
[...]

This happens until the clients are closed. When the iOS client is switched to background, the requests keep going, but at a slower pace. When the server is stopped and restarted, it picks up right away when giving the macOS client focus. IOW this happens all the time while a client is connected.

The bandwidth consumed is a continuous 30-35KB/sec upload and twice that as download to the client, per client.

This effect is present back in v0.6.6, but doesn't happen in v0.6.4.

Diff between the two versions: https://github.com/mdouchement/standardfile/compare/v0.6.4...v0.6.6

To rule out a client issue, I also tested this with an account on the official server and everything was normal in that case, with network activity only while editing notes, and no traffic while idle.

mdouchement commented 1 year ago

There is no change except a new route for items that use the same logic as the old route. May be the official client/server implemented hidden feature(s). I don't how it works in background because I don't use it.

I don't have much requests per second using the webapp. Did you remove an item/tag recently? (cf. #87) You can check that issue by logout/login the client(s).

vszakats commented 1 year ago

@mdouchement Thank you very much for your reply, and your server of course!

I did not use tags, only a couple of notes with minimal text. But, you're right and this indeed seems to be related to #87. I could just replicate it with a third fresh test account and the flood started right away after emptying the trash on one device. Signing out and back in stopped it.

Thanks again and closing this as a duplicate of #87.