Back

appwrite-usage container high cpu usage

  • 0
  • Self Hosted
WhiteWalker72
2 Nov, 2023, 15:48

Hi, i'm running a t2.small EC2 instance with Appwrite but i'm currently bumping into cpu usage issues. Apprently the appwrite-usage container is using more than 50% cpu. The total cpu usage went to 100%.

Is there anything I can do about this cpu usage? I'm currently running Appwrite 1.4.5. Is a t2.small EC2 instance sufficient to run Appwrite or do I need to upgrade?

TL;DR
The user is experiencing high CPU usage with the appwrite-usage container. They tried disabling usage and upgrading the server, but now they are getting an internal server error when trying to view usage. The error message indicates a TypeError. The user also mentions changing the _APP_USAGE_AGGREGATION_INTERVAL and disabling the usage container. They are unsure how to fix the issue. Suggestions from other users include modifying the interval, disabling usage via the _APP_USAGE_STATS environment variable, and checking if the amount of requests is abnormally high. There is no definitive solution provided in the thread.
WhiteWalker72
3 Nov, 2023, 06:30

CPU usage went back to normal levels but I sometimes see spikes from the appwrite usage container :/

WhiteWalker72
3 Nov, 2023, 11:03

It sadly happened again, I stopped the appwrite-usage container for now but it would definitely be nice to know why this is happening

Drake
3 Nov, 2023, 18:24

yes, the usage container does a lot of work every _APP_USAGE_AGGREGATION_INTERVAL seconds. this container is responsible for aggregating a lot of data for the usage data you see in the project overview

Drake
3 Nov, 2023, 18:24

you can try tweaking the interval

Drake
3 Nov, 2023, 18:25

you can also try disabling usage via the _APP_USAGE_STATS env var if you don't need it

WhiteWalker72
6 Nov, 2023, 08:53

Thank you @Steven! I didn't know about those env variables. If I enable usage stats the usage container will just claim 50% cpu and keeps doing that. Could it be that amount of requests is very high? In the dashboard it shows 22k requests on a single day even though we don't have any users. We are just using this instance for development. Is 22k requests on a single day normal usage for a small development team of 4 devs?

D5
6 Nov, 2023, 09:33

If this was during peak hours, I think it's a normal usage, having in mind you just have 1 core server. You could just modify the interval as Steven said to distribute load having

WhiteWalker72
6 Nov, 2023, 13:07

Thank you for your response. I upgraded to a 2 core server now. The CPU is fine but usage is now broken. Whenever I try to view usage of anything I get an internal server error back This is the error on the server:

TypeScript
[Error] Method: GET
[Error] URL: /v1/functions/:functionId/usage
[Error] Type: TypeError
[Error] Message: Appwrite\Utopia\Response::dynamic(): Argument #1 ($document) must be of type Utopia\Database\Document, array given, called in /usr/src/code/app/controllers/api/functions.php on line 542
[Error] File: /usr/src/code/src/Appwrite/Utopia/Response.php
[Error] Line: 481
[Error] Timestamp: 2023-11-06T13:03:34+00:00

Could it be caused because I had changed the _APP_USAGE_AGGREGATION_INTERVAL to 60 and disabled the usage container? Not sure how to fix this now πŸ˜…

D5
6 Nov, 2023, 15:03

That's weird πŸ‘€

D5
6 Nov, 2023, 15:04

If you disabled usage, then that's why it's not working, unless you started it again

WhiteWalker72
6 Nov, 2023, 15:06

Hm I still wouldn't expect an internal server error when disabling usage but I will enable it again to see if the problem resolves itself that way

Drake
6 Nov, 2023, 21:00

ya...looks like a regression πŸ˜•

Drake
6 Nov, 2023, 21:33
WhiteWalker72
7 Nov, 2023, 07:33

Ah great a PR is open for that πŸ™‚

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more