-
Notifications
You must be signed in to change notification settings - Fork 455
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Spread connections across multiple gateways #62
Comments
It looks like the DNS is round-robined on Apple’s side, but the TTL is 60 seconds, so it would presumably only affect connections made more than a minute apart. |
I wonder do Apple just intend for clients to to open more than one connection to APNS? If they have only 8 end-points, then each end-point must be able to handle a large number of push notifications per-second. I assume 2 connections to the same end-point is faster than one. /CC @jmason |
Probably true. A tech note from Apple suggests that we ought to be able to get ~9k notifications/second through a single connection, but I'm not sure how they arrived at that number.
Maybe, but the main benefit there may just be that you have one connection still going if the other closes due to a rejected notification and needs to spend time reconnecting. That said, that's purely speculation on my part. This bit from the docs makes me think that we'd want to spread across multiple different endpoints for maximum throughput:
(emphasis added) |
Now that we live in a post-HTTP/2 world, I'm actually thinking this isn't a great idea. To recap, the main benefits in the past were:
Now that connections don't close every time a notification gets rejected, the connection resilience isn't something we need to worry about in quite the same way, and I think the benefit provided by multiple connections would be negligible in nearly all cases. The second point—spreading requests across upstream resources—may still be A Thing, but it seems like we'd have to add an enormous amount of complexity (DNS resolution, pooled connections, etc.) to get there. It also seems like we'd only see gains in cases where we're saturating a CPU core (and could benefit from using more cores) for a single topic, but aren't close to saturating a network connection. I suspect most users who are sending zillions of notifications are generally sending them (a) on multiple topics or (b) from multiple servers. My inclination right now is to close this unless somebody chimes in saying "this is totally my use case!" What do you all think? |
I would be in favour of closing this, too. The primary use case was to deal with the rejected-notification-causes-connection-close lossage, which is no longer an issue (thankfully). Users who still want greater performance, or more resilience, by using multiple parallel connections will probably have parallelism further up the stack -- ie. using multiple parallel ApnsClients, or multiple servers (as you suggested). (I know we do!) |
Closing for now, but will certainly be listening for comments. |
I am working on this currently. We have over 3 million messages to push in one hour with 6 nodes concurrently. Maybe 3~4 sending tasks per day. Every node of the six has a separate wan-ip communicating with gateways. I try to restart the instance in poor performance and maybe i get different result, but hardly reach the performance of node B, and hardly select the same ip as node B did. So i assume several possible reasons: i. the loads of different gateway are different. And i am doing various experiments to figure it out now. |
According to the APNs docs:
No further guidance is given as to how that might happen, though. We had previously assumed that connection-spreading would happen automatically, but that does not appear to be the case in testing. It looks like there are a number of IPs associated with the gateway's DNS entry:
To spread connections across multiple gateways, it seems like we'll need to do our own DNS resolution and connect directly by IP.
The text was updated successfully, but these errors were encountered: