Skip to content

APNS HTTP 2 Push Speed

Adam Jones edited this page May 23, 2017 · 2 revisions

How fast can I push using APNS/2?

The correct answer to this will depend on many factors such as: CPU speed, CPU cores, Ram, Network speed, Network latency, Notification payload size etc — This page is intended only as an approximate guide to the rough speed/throughput that you can potentially achieve using APNS/2.

These are not true benchmarks, but rather quick tests to give an idea under different scenarios.

Results

Region Machine Type Cores Ram Network Speed
us-west-1 m3.medium 1 3.75 gb Moderate 4,023 p/sec
us-west-1 m4.xlarge 4 16 gb High 21,413 p/sec
us-west-1 m4.4xlarge 16 64 gb High 64,516 p/sec
us-west-1 m4.16xlarge 64 256 gb 20 Gigabit 105,263 p/sec

Notes

  • Tests were run Using Go 1.8.1 and APNS/2 v0.10
  • Tests were run using Docker (Via Amazon ECS).
  • Tests were run on the APNS Production gateway.
  • The Push payload was 26 bytes.
  • Speed is p/sec calculated as the average across 10 batches.
  • Each test batch had 100,000 notifications.
  • To keep things simple, one client instance was used per CPU core.

Example Code

The code run was very basic and similar to the following;

cores := runtime.NumCPU()
runtime.GOMAXPROCS(cores)

clients = make(chan *apns2.Client, 50)

cert, err := certificate.FromP12File("./Certificates.p12", "")
if err != nil {
  log.Fatal("cert error:", err)
}

for i := 0; i < runtime.NumCPU(); i++ {
  // create an apns2 Client per CPU core
  clients <- apns2.NewClient(cert).Production()
}

var wg sync.WaitGroup
for i := 0; i < int(100000); i++ {
  client := <-clients // grab a client from the pool
  clients <- client // add the client back to the pool
  wg.Add(1)
  go func() {
    // grab a notification from your channel filled with notifications
    notification := <-notifications
    res, err := client.Push(notification)
    // handle response or error
    wg.Done()
  }()
}
wg.Wait()
Clone this wiki locally