whatsapp-web.js icon indicating copy to clipboard operation
whatsapp-web.js copied to clipboard

High Memory Usage Due to Remote Auth Caching in wwebjs_auth File

Open HosseinBabmoradi opened this issue 1 year ago • 35 comments

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

  1. Enable remote auth in the application.
  2. Run the application with a significant number of users (e.g., 70 customers).
  3. 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

HosseinBabmoradi avatar Jul 23 '24 12:07 HosseinBabmoradi

Agree, its happed after webcacheversion remove

Hasnen-mr avatar Jul 23 '24 13:07 Hasnen-mr

it happend to me, what coud be the problem?

VigilioYonatan avatar Jul 27 '24 08:07 VigilioYonatan

Same issue, it takes forever for loading up and for the client get ready.

AKwoKWH avatar Aug 06 '24 03:08 AKwoKWH

any update for this? its happen to me. and when service restart, more client sign out automaticly

ingGhost avatar Aug 07 '24 14:08 ingGhost

Same issue here, I'm sure there is a way to reduce the memory usage....

olivierb24 avatar Aug 13 '24 20:08 olivierb24

same issue, causing my VM frozen and not responding

AKwoKWH avatar Sep 02 '24 15:09 AKwoKWH

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. 😔

postguruji avatar Sep 26 '24 13:09 postguruji

it is now unusable when you use the saved auth. Because when it starts it seems load a massive file and the machine hang.

AKwoKWH avatar Oct 01 '24 12:10 AKwoKWH

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'
        ]

correamarques avatar Oct 07 '24 20:10 correamarques

any update for this?

AnDyro751 avatar Oct 29 '24 23:10 AnDyro751

+1 here. RAM consumption keeps going up every day.

templargin avatar Nov 02 '24 17:11 templargin

+1 here. There should be a way to clean this directory by removing all useless files and keeping only the session credentials data

paulocesar-ufu avatar Nov 29 '24 13:11 paulocesar-ufu

+1

amao12580 avatar Dec 05 '24 08:12 amao12580

+1

pedropuppim avatar Dec 09 '24 16:12 pedropuppim

+1

alexMtzRivero avatar Dec 10 '24 15:12 alexMtzRivero

+1

N0N4M3BNS avatar Dec 13 '24 07:12 N0N4M3BNS

+1

karik741 avatar Dec 21 '24 12:12 karik741

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 😨

paulocesar-ufu avatar Dec 21 '24 19:12 paulocesar-ufu

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

sam-lex avatar Dec 23 '24 12:12 sam-lex

@HosseinBabmoradi or any developers here, how are you coping with this issue at the production level?

yongquanben avatar Jan 02 '25 02:01 yongquanben

@yongquanben Every two to three days, I restart the application and I also delete the wwebjs_auth folder

HosseinBabmoradi avatar Jan 03 '25 16:01 HosseinBabmoradi

This is bad...

chrome_BsCQy9xnNa

matifanger avatar Jan 15 '25 19:01 matifanger

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

Image

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

Image

This is how you can change this parameter and make tests.

Image

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. 😥

Image

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

wis-dev avatar Jan 24 '25 18:01 wis-dev

+1

fpswagg avatar Mar 03 '25 20:03 fpswagg

+1

KaannKara avatar Mar 05 '25 01:03 KaannKara

+1

BigBox2 avatar Mar 12 '25 07:03 BigBox2

Any one figured a fix for this ?

OmarHegazi94 avatar Apr 08 '25 19:04 OmarHegazi94

Same issue here :( I hope someone can find a solution...

sheepbild avatar May 08 '25 00:05 sheepbild

Does this happen when Local Auth is used?

ethan-tqa avatar Jun 11 '25 04:06 ethan-tqa

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.

FelipeJz avatar Jun 11 '25 13:06 FelipeJz