Hi, I’m Josh Symonds

I blog about Ruby on Rails, coding, and servers

Rapnd: Redis APN Daemon

Reading time 1 minute

rapnd is a gem I developed to create a persistent connection through which to pass messages to Apple’s Push Notification servers. It’s pretty neat and you should check it out.

Why another push notification gem?

The existing ones just didn’t do what I wanted. There were some that created persistent daemon connections… but they were only usable with one app, and we have two apps we want to send push notifications for. There were some with multiple app support, but they didn’t have daemons or they assumed the existence of ActiveRecord. And in my opinion using ActiveRecord to store notifications is pretty dumb.

Whoa! ActiveRecord is just fine, bro.

Yeah, I love ActiveRecord. But it’s clearly the wrong storage solution for push notifications. For every single push notification we send, we couldn’t care less about the content or whether or not it was actually delivered – so storing them in the database just built a huge table that we ended up not needing at all. Redis is the perfect solution: it can handle arbitrarily-sized lists, but doesn’t bother with any significant kind of persistence. Also, blpop made the programming a breeze.

Why a daemon?

Well, Apple tells you to do it. But for a more important reason, Apple claims that constantly established and dropped connections to their servers will result in IP blacklisting. I’ve never actually seen this in practice, but… well… why chance it? rapnd uses one connection per daemon and tries to keep it open as long as possible.

So yeah, it’s pretty cool. Go check out the rapnd github page to see the deets.

Josh Symonds performs devops and server wrangling on cloud-scale infrastructures, deploys amazing web applications with Ruby on Rails, and creates awesome iOS apps with Objective-C and RubyMotion. He is founder and CTO of Symonds & Son, a development shop focused on quality and excellence.

Josh Symonds