Apple 推送通知服务 - 发送许多通知
我现在正在尝试开发服务器的一部分,该部分将处理向 APN(然后向 iphone)发送通知。 事实上,它是在我的服务器上运行的专用服务。每 15 分钟,该服务就会在我的 MySQL 数据库中查找要发送的通知。
我已经处理了所有证书部分,并且我正在尝试定义实施该部分的最佳策略。 Ì 计划使用:
- 启动 Java 服务器的 cron 作业
- 使用 java-apns 的 Java 服务器
我对此有两个问题:
- 您对我计划做什么有什么建议吗?
- 由于每 15 分钟我会发送大约 1000 条通知(1x 到 1000 部电话),是否有特殊的方法来处理这种过载?
感谢您的帮助 !
凯劳德
I am now trying to develop the part of my server which will handle sending notifications to APN (then to iphones).
In fact, it is a dedicated service running on my server. Every 15 minutes, this service looks in my MySQL database for notifications to send.
I have deal with all the certificate part, and I am trying to define the best strategy to implement that.
Ì plan to use :
- A cron job which fires a Java server
- A java server using java-apns
I have two questions regarding that :
- Do you have advice regarding what I plan to do ?
- As every 15 minutes I will send around 1 000 notifications (1x to 1 000 phones), is there a special way to hande this overload ?
Thanks for your help !
Kheraud
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我不知道你为什么要每 15 分钟运行一次这项工作。该时间间隔对您的应用程序是否重要,或者是某个任意数字?在我的其余回答中,我假设是后者。
您需要创建一个后台进程来保持与 APNS 的永久连接打开。这比从 cron 作业运行程序更好,因为一遍又一遍地设置 SSL 连接非常昂贵。 (虽然如果你真的想坚持 15 分钟的事情,我想从 cron 作业运行也不错。只是不要为你想要发送的每个通知打开和关闭连接。)
而不是发送 1000 个通知每 15 分钟,每分钟发送 100 条通知。或者更确切地说,每秒发送一些通知。
如果您有大量通知要发送,您可以为同一应用程序打开多个与 APNS 的连接(但不超过 15 个)。
为了获得极高的效率,您可以在发送到 APNS 的每个数据包中捆绑多个通知(例如使用 Nagle 算法)。
I'm not sure why you want to run this job every 15 minutes. Is that time interval significant to your app, or is it some arbitrary number? In the rest of my answer I'm assuming the latter.
You need to create a background process that keeps a permanent connection open to APNS. This is better than running your program from a cron job because setting up the SSL connection over and over is very expensive. (Although if you really want to stick to the 15 minute thing, I suppose running from a cron job is not so bad. Just don't open and close a connection for every notification you want to send out.)
Instead of sending 1000 notifications every 15 minutes, send 100 notifications every minute. Or rather, send a few notifications every second.
If you have a lot of notifications to send, you can open multiple connections to APNS for the same app (but no more than 15).
For extreme efficiency, you can bundle multiple notifications in each packet you send to APNS (for example using Nagle's algorithm).