parse-server icon indicating copy to clipboard operation
parse-server copied to clipboard

Crashing on sending push to all users

Open candork opened this issue 10 years ago • 7 comments

I have around 300k users on my parse app. After trying to send push from the dashboard, the server crashed. Looks like its running out of memory, any hints on how to solve it?

Thanks!

Here are the logs

verbose: POST /parse/push { host: 'localhost:1337',
  connection: 'keep-alive',
  'content-length': '237',
  origin: 'http://0.0.0.0:4040',
  'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_10_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.110 Safari/537.36',
  'content-type': 'text/plain',
  accept: '*/*',
  referer: 'http://0.0.0.0:4040/apps/parseapp/push/new',
  'accept-encoding': 'gzip, deflate',
  'accept-language': 'en-US,en;q=0.8' } {
  "where": {},
  "data": {
    "alert": "test"
  }
}
verbose: {
  "headers": {
    "X-Parse-Push-Status-Id": "qMkeE3BVa0"
  },
  "response": {
    "result": true
  }
}

<--- Last few GCs --->

  152472 ms: Mark-sweep 1386.1 (1457.9) -> 1394.1 (1457.9) MB, 1856.4 / 0 ms [allocation failure] [GC in old space requested].
  154362 ms: Mark-sweep 1394.1 (1457.9) -> 1394.7 (1457.9) MB, 1889.6 / 0 ms [allocation failure] [GC in old space requested].
  156230 ms: Mark-sweep 1394.7 (1457.9) -> 1385.1 (1457.9) MB, 1867.7 / 0 ms [last resort gc].
  158107 ms: Mark-sweep 1385.1 (1457.9) -> 1386.0 (1457.9) MB, 1877.3 / 0 ms [last resort gc].


<--- JS stacktrace --->

==== JS stack trace =========================================

Security context: 0x3bc143fe3ac1 <JS Object>
    1: untransformObject [/Users/r/Documents/r/parseapp/Dev/app/Backend/parse-backend/node_modules/parse-server/lib/Adapters/Storage/Mongo/MongoTransform.js:~629] [pc=0x29ec8acc8e0] (this=0x1f987c184911 <an Object with map 0x10fad3e3be69>,schema=0x15115fb97e11 <a Schema with map 0x1cd3aeaf0e29>,className=0x27561321f2a9 <String[13]: _Installation>,mongoObject=0x688afe44731 <an Objec...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - process out of memory
Abort trap: 6
Rashids-iMac:parse-backend r$ 

candork avatar Apr 28 '16 04:04 candork

I think parse-server needs to be chunking and yielding to the event loop on this, background-compute is a good example.

Looks like its the deserialisation from the mongo transform. Similar issue on the sails-mongo adapter: https://github.com/balderdashy/sails-mongo/pull/369 but this is more of a blocking event loop issue.

Salakar avatar May 04 '16 16:05 Salakar

Parse Server push isn't designed for high throughput, so with 300k users, you will need a lot of memory to push to all of them. Some workarounds might be to use another push provider (Urban Airship, Facebook analytics push, One Signal) or to increase the memory on your instance before sending a push, or to send pushes to smaller batches of users.

drew-gross avatar May 06 '16 19:05 drew-gross

I also faced the same issue when trying to send push to 30k users (all users). I had to increase the memory limit 10 time more to fix the issue :(

Jinoooo avatar Jun 13 '16 19:06 Jinoooo

@Jinoooo how did you increase the memory issue?

candork avatar Jun 13 '16 19:06 candork

Just increased the allocated memory on AWS hosting server. Wondering how parse.com is addressing this issue. Any plan to fix this roadblock?

Jinoooo avatar Jun 13 '16 19:06 Jinoooo

You can also change your code to send it to a smaller group based on your memory limit. In your case for 300K, you may need to break it to 10k bucket each time and repeat the process 30 times, ugly I know.

Jinoooo avatar Jun 13 '16 19:06 Jinoooo

We're closing this issue due to inactivity.

If this is a bug you care about that is not getting attention, consider opening a pull request with a fix.

hramos avatar Jul 27 '16 22:07 hramos