0

Folks, if anyone has used Pushy for sending Apple Notifications to Apple devices, I have a basic question about the ApnsClient.

The documentation claims that a "client can be configured to use only one connection", but the only way to do this AFAIK is to use the client synchronously (no lambdas); perhaps it can be configured thus, but I don't see how.

More importantly though, if a EventLoopGroup (i.e. threadpool) can be specified while creating a client, why is there a need to ever create more than one ApnsClient?

Pushy is built on Netty, an asynchronous event-driven network application framework. Netty relies heavily on the notion of "event loops", which execute tasks in series on a single thread. In Pushy, a single connection to the APNs server is bound to a single event loop, and thus a single thread. Callers may configure ApnsClient instances to open multiple concurrent connections to the APNs server and to use EventLoopGroups (essentially thread pools for event loops) of varying sizes.

Because connections are bound to a single event loop (which is bound to a single thread), it never makes sense to give an ApnsClient more threads in an event loop than concurrent connections. A client with an eight-thread EventLoopGroup that is configured to maintain only one connection will use one thread from the group, but the other seven will remain idle. Opening a large number of connections on a small number of threads will likely reduce overall efficiency by increasing competition for CPU time.

paiego
  • 3,619
  • 34
  • 43
  • I think the answer may simply be that a single ApnsClient is associated with one and only one certificate, and thus bundle id. – paiego Aug 21 '20 at 21:57

1 Answers1

0

I am using Pushy. There is option to set number of concurrentConnections (builder.setConcurrentCOnnection()). So my understanding is for one Client we can have multiple concurrent connections. However i am trying to figure our how to set Size of thread pool(EventPoolGroup).Thread pool size and no of concurrentConnections should be equal,to have 1 connection per thread. I think we need multiple objects of APNSClient only when We need to connect to different Topics on APN server.Even one APNSClient can connect to multiple topics but to keep Calls separate for different topic we can have different APNS Client object.You would be able to separate the Connection configuration based on traffic.