parse-server
parse-server copied to clipboard
Provide a way to disable recording PushStatus
As I have my own mechanism to log my Push Status so it would be better if we can disable recording PushStatus via Parse Server constructor.
The _PushStatus is meant to be used in Parse dashboard. Why would you need to disable it?
As Florent mentioned, this is here to provide support for the dashboard, and it was a requested feature. Not sure why we'd turn this off, but a PR would be reviewed. Thanks.
I see a point in being able to turn the logging off. It will grow the database by a huge amount if push is used frequently for an app.
I would also like a way to turn off push status or at least a mechanism to clean them after a expire time. this will save lots of db space.
you can easily drop the _PushStatus collection right from mongoDB. have a cron that cleanup old data/archive etc...
I know this bug is rather old but here is a snippet of the cloud code that I'm using to remove _PushStatus entries once the push goes though to avoid growing the collection indefinitely.
Perhaps it will help somebody:
Parse.Cloud.afterSave('_PushStatus', (req, res) => {
const obj = req.object
const x = obj.get("status")
if (x === 'succeeded' || x == 'failed') {
Parse.Object.destroyAll([obj], {
success: function() {
},
error: function(error) {
console.log("[afterSave] _PushStatus status '" + x + "' Parse.Object.destroyAll failed with error code: " + error.code)
},
useMasterKey: true
})
}
});
Well, the biggest reason not to store PushStatus is that sending millions of push notifications at the same time writes millions of rows and gets a lot of unneeded traffic to database.
I’d like to revisit this feature request. My system sends a huge number of push notifications, which leads to the PushStatuses taking up significant database space. I really need a way to disable this logging.
A workaround is to set a TTL index (for MongoDB) on the collection. So documents get deleted after a certain amount of time automatically on the DB level, without Parse Server needing to make another request. This is an advantage compared to setting an afterSave trigger.
A solution may be to set a beforeSave trigger, to avoid the document being sent to the DB. I'm not sure whether throwing an error is a way to stop saving the entry, or whether that causes other issues in Parse Server. Would have to try out.
In any case, this is reopened to implement a feature to add a Parse Server config that allows to disable push logging. Also adding a bounty, as this may indeed be a significant performance improvement for apps with high push load.
Thanks for opening this issue!
A workaround is to set a TTL index (for MongoDB) on the collection. So documents get deleted after a certain amount of time automatically on the DB level, without Parse Server needing to make another request. This is an advantage compared to setting an afterSave trigger.
A solution may be to set a
beforeSavetrigger, to avoid the document being sent to the DB. I'm not sure whether throwing an error is a way to stop saving the entry, or whether that causes other issues in Parse Server. Would have to try out.In any case, this is reopened to implement a feature to add a Parse Server config that allows to disable push logging. Also adding a bounty, as this may indeed be a significant performance improvement for apps with high push load.
I’m currently using the afterSave trigger to delete _PushStatus. It works, but constantly creating and removing a large number of entities is somewhat wasteful. Having an option to turn this off permanently would be great.
Just for completeness... this is the TTL based index that makes it easier to get rid of _PushStatus entries automatically after some time. The key is "expireAfterSeconds" : 300
db.getCollection('_PushStatus').getIndexes()
[
{
"v" : 1,
"key" : {
"_created_at" : 1
},
"name" : "_created_at_1",
"background" : true,
"expireAfterSeconds" : 300
},
{
"v" : 1,
"key" : {
"pushHash" : 1
},
"name" : "pushHash_1",
"background" : true
},
{
"v" : 1,
"key" : {
"_id" : 1
},
"name" : "_id_"
}
]
I wonder how difficult it really is to add an option to disable writing to PushStatus in the first place. Has anyone looked into that? I doubt this is complex. It may impact other features like scheduled push, but that can simply be addressed with a caveat in the docs. The write is really the expensive operation we want to get rid of.