High Memory Usage Due to Remote Auth Caching in wwebjs_auth File
Is there an existing issue for this?
- [X] I have searched the existing issues
Describe the bug
I'm experiencing significant memory usage problems with the remote auth feature in my application. Specifically, the caching of data in the wweb_auth file is causing my server to consume a large amount of RAM, around 20GB, which is unsustainable. I have around 70 customers, and the frequent synchronization with MongoDB (every 60 seconds) is not alleviating the memory pressure.
Expected Behavior
I would expect the remote auth mechanism to handle authentication data more efficiently, without causing excessive memory usage. Ideally, it should be possible to configure it to use less RAM or to avoid keeping large amounts of data in memory.
Actual Behavior
The wweb_auth file caching mechanism is causing the application to consume around 20GB of RAM. This high memory usage is not sustainable and leads to performance issues.
Steps to Reproduce the Bug or Issue
- Enable remote auth in the application.
- Run the application with a significant number of users (e.g., 70 customers).
- Observe memory usage over time.
Relevant Code
No response
Browser Type
Chromium
WhatsApp Account Type
Standard
Does your WhatsApp account have multidevice enabled?
Yes, I am using Multi Device
Environment
- whatsapp web js: [pedroslopez/whatsapp-web.js#webpack-exodus]
- Node.js Version: [v21.7.2]
- Operating System: [Windows]
Additional context
No response
Agree, its happed after webcacheversion remove
it happend to me, what coud be the problem?
Same issue, it takes forever for loading up and for the client get ready.
any update for this? its happen to me. and when service restart, more client sign out automaticly
Same issue here, I'm sure there is a way to reduce the memory usage....
same issue, causing my VM frozen and not responding
Facing an issue with whatsapp-web.js on Ubuntu. Initially, the RAM usage is around 40% but after 5 to 7 hours of running with the same sessions (no new sessions added), the RAM usage gradually increases to 100%, causing performance issues. 😔
it is now unusable when you use the saved auth. Because when it starts it seems load a massive file and the machine hang.
I was experiencing the same issue after deployment on Heroku. Before this change my app was consuming in average 570mb, now the average is 330mb.
I add some args in the puppeteer options in the file sessions.js inside the clientOptions block:
headless: true,
args: [
'--no-sandbox',
'--disable-setuid-sandbox',
'--disable-gpu',
'--disable-dev-shm-usage',
'--disable-accelerated-2d-canvas',
'--disable-web-security',
'--disable-features=IsolateOrigins,site-per-process',
'--disable-features=VizDisplayCompositor',
'--single-process',
'--no-zygote',
'--renderer-process-limit=1',
'--no-first-run',
'--no-default-browser-check',
'--disable-background-networking',
'--disable-background-timer-throttling',
'--disable-backgrounding-occluded-windows',
'--disable-breakpad',
'--disable-client-side-phishing-detection',
'--disable-component-update',
'--disable-default-apps',
'--disable-domain-reliability',
'--disable-extensions',
'--disable-hang-monitor',
'--disable-ipc-flooding-protection',
'--disable-notifications',
'--disable-offer-store-unmasked-wallet-cards',
'--disable-popup-blocking',
'--disable-prompt-on-repost',
'--disable-renderer-backgrounding',
'--disable-sync',
'--force-color-profile=srgb',
'--metrics-recording-only',
'--mute-audio',
'--no-crash-upload',
'--no-pings',
'--password-store=basic',
'--use-gl=swiftshader',
'--use-mock-keychain',
'--disable-software-rasterizer'
]
any update for this?
+1 here. RAM consumption keeps going up every day.
+1 here. There should be a way to clean this directory by removing all useless files and keeping only the session credentials data
+1
+1
+1
+1
+1
Just for you know:
My .wwebjs_auth directory size evolution:
- after first authentication: 70mb
- after 3 days: 300mb
- after 1 week: 700mb
- after 2 weeks: 2gb 😨
mine crashes everything after it reaches around 5-6 Gb. I usually know it's time to delete .wwebjs_auth when it starts crashing during loading, or when my computer starts freezing.. (about once a week)...
I just cleared and restarted my app today, and it's been running for 5 hours now, currently it's at 206 mb
@HosseinBabmoradi or any developers here, how are you coping with this issue at the production level?
@yongquanben Every two to three days, I restart the application and I also delete the wwebjs_auth folder
This is bad...
The arguments provided by @correamarques helped me reduce RAM usage a bit.
This is my server consumption after initialize and authenticate my client with RemoteAuth and AwsS3Store on a Production Environment.
Tech specs:
- 16 GB RAM
- 4 vCPUs
Using Remote Auth Strategy with AWS S3 Store you will have automatic backups. This is the bandwidth usage generated. THIS DO NO CAUSE MORE RAM USAGE
This is how you can change this parameter and make tests.
See more at this example: https://github.com/arbisyarifudin/wwebjs-aws-s3?tab=readme-ov-file#example-usage
The high memory usage is not ocationated by the Remote Auth Caching Sync.
Besides i face this same issue in other escenario. This happens when you initialize a client and then do nothing. It stays active forever and causes the RAM problem. Actual solution: Restart the server. 😥
I try many things... increasing server RAM, adding client arguments to reduce consumption, but it keeps happening. I love this library and hope someone can solve this problem we are facing.
@pedroslopez @alechkos @purpshell
+1
+1
+1
Any one figured a fix for this ?
Same issue here :( I hope someone can find a solution...
Does this happen when Local Auth is used?
In my experience this issue does not exists in Local Auth. I ended up using it instead as RemoteAuth leaks ram for some reason. I did some tests using remote folders externally with sshfs, managed to connect successfully but is pretty slow as expected. Maybe using another external sync solution could work for Local Auth, haven't look into that though.