freswa / dovecot-xaps-daemon

MIT License
49 stars 10 forks source link

Feature request: Database for the daemon #17

Open Fogelholk opened 2 years ago

Fogelholk commented 2 years ago

Currently the database is handled by a json-file, very simple and probably works fine for most cases, but I would say it might be inadvisable to use a JSON file rather than a "real" database of some kind if you have many users with xaps enabled.

This is a feature request for having some kind of database instead of a single database.json-file, be it Redis, Postgresql, Mariadb or something else for better scaling.

Also, is there some information from Apple how they handle "heavy users" of the notifications, rate-limiting or blocking the App Store account used for purchasing MacOS Server? (Found this, not sure if it is applicable https://developer.apple.com/library/archive/technotes/tn2265/_index.html#//apple_ref/doc/uid/DTS40010376-CH1-TNTAG44)

Thank you for this really awesome project, really love how simple it was to set up :)

freswa commented 2 years ago

Thank you for bringing this up. I made a rollout of the daemon at a client with > 200k customers and the code is optimized for larger installations. With this in mind, a database setup will blow up the code, the setup process and will be less reliable than the current approach. If there are good reasons, I'll add db support.

No there is no documentation for rate-limiting etc.

Fogelholk commented 2 years ago

Thanks for the info! That's good to know, and yeah adding database support will increase the codebase immensly, but if it works as it is now I can't complain, just checking before implementing it on our systems :)

May I ask how you've solved running the xaps deamon. Are you running the daemon itself on multiple Dovecot nodes (I assume you're running multiple dovecot nodes for the big client), or one instance of xapsd somewhere that all dovecot nodes connect to?

freswa commented 2 years ago

May I ask how you've solved running the xaps deamon. Are you running the daemon itself on multiple Dovecot nodes (I assume you're running multiple dovecot nodes for the big client), or one instance of xapsd somewhere that all dovecot nodes connect to?

The latter :)

Fogelholk commented 2 years ago

Been running xapsd for a couple of days now and seems to be pretty lightweight even with many thousands of accounts, around 60k seems to have iOS devices and are picked up by xapsd :)

This request is mostly because I like having redundant systems everywhere, a database would mean I could have two xapsd servers running with the same database backend, and one node could be taken down for maintenance if needed and all iOS users would not see any delays in notifications.

Just a nice to have feature which can be worked around with just having two xapsd-nodes inpedendent of each other and letting iOS devices be picked up by the other xapsd node if a failover occurs of course, since a database backend really increases the softwares footprint.

If the request is too troublesome it can be closed, I'm still happy with it!

pelletierr commented 1 year ago

I agree with Fogelholk. I am running a master-master setup of Dovecot with postfix data in a master-master replicated database. Having a MySQL backend to store the device registrations would remove a weird behavior of no notification sent, because both servers would know about all devices registrations.

My goal was to have completely redundant servers and being able to shut one down without functionality losses.

Thanks for considering that kind of setup!

pelletierr commented 1 year ago

Thinking about it, if only a way to sync registrations between xapsd servers would was implemented, it would do the trick.