简体   繁体   English

苹果推送通知服务-许多通知要发送

[英]Apple Push Notification Service - Many notifications to send

I am now trying to develop the part of my server which will handle sending notifications to APN (then to iphones). 我现在正在尝试开发服务器的一部分,该部分将处理向APN(然后向iphone)发送通知的过程。 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. 每隔15分钟,此服务就会在我的MySQL数据库中查找要发送的通知。

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 触发Java服务器的Cron作业
  • A java server using java-apns 使用java-apns的Java服务器

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 ? 由于每15分钟我会发送大约1000条通知(从1x到1000电话),是否有特殊的方法来处理这种超载?

Thanks for your help ! 谢谢你的帮助 !

Kheraud Kheraud

I'm not sure why you want to run this job every 15 minutes. 我不确定为什么要每15分钟运行一次此作业。 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. 您需要创建一个后台进程,以保持与APNS的永久连接打开。 This is better than running your program from a cron job because setting up the SSL connection over and over is very expensive. 这比从cron作业中运行程序要好,因为一遍又一遍地建立SSL连接非常昂贵。 (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.) (尽管您确实想坚持15分钟,但我想从cron作业运行起来还不错。只是不要为要发送的每个通知打开和关闭连接。)

Instead of sending 1000 notifications every 15 minutes, send 100 notifications every minute. 而不是每15分钟发送1000条通知,而是每分钟发送100条通知。 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). 如果要发送的通知很多,则可以为同一应用打开与APNS的多个连接(但最多不超过15个)。

For extreme efficiency, you can bundle multiple notifications in each packet you send to APNS (for example using Nagle's algorithm). 为了获得极高的效率,您可以在发送到APNS的每个数据包中捆绑多个通知(例如,使用Nagle的算法)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM