At launch Pushover was a Rails 3 application behind Apache on one of the author's OpenBSD servers. The HTTP API wrote messages to a MySQL queue table, and a separate daemon polled that table every second and dispatched them to Google's C2DM and Apple's APNS. Android and iOS apps then synchronised their messages from the server over SSL.
Section: January 20: API Development and Rails 3 | Section: January 21: iOS Changes my Plans
Components
Component
Role
Where
HTTP API
A Rails 3 application that accepts messages, handles user and device registration, and serves the message synchronisation calls the apps use.
Section: January 20: API Development and Rails 3 | Near: adding the message synchronization calls to the Rails
Queue table
A MySQL table that incoming messages are written to and that the dispatch process reads.
Near: Messages are written to a queue table
Message dispatch daemon
A small separate process that reads the queue table every second and pushes messages out to Google's and Apple's push servers.
Near: I wrote a small daemon to read | Near: polls the queue table every second
Android and iOS apps
Device clients that receive the push notification and download their messages from the server over HTTP, keeping a local database in sync.
Section: January 21: iOS Changes my Plans
Website
Splash page plus logged-in pages for enabling and disabling devices, creating apps, sending messages and reading the API documentation. Apache serves a static copy of the splash page to visitors without a cookie.
Section: January 29: Website Work | Section: February 28: Load Testing and Monitoring
Network monitor
The author's own monitor polls the queue length through an authenticated API call and checks the static and API sites, sending text messages when a Pushover component fails.
Queue outgoing notifications in a MySQL table polled every second, not in a message broker
pushover-2012-launch-stack#d1at corpus version 26a1b3a7e3dd
Chosen
Messages are written to a MySQL queue table. Once a second a separate process reads that table and hands what it finds to the push servers of Google (C2DM) and, from later in development, Apple (APNS).
Near: Messages are written to a queue table
Rejected
A queue system such as ActiveMQ or ZeroMQ, or a NoSQL store. The author calls those fancy and says he went with a setup he describes as boring but reliable.
Near: Rather than use a fancy queue setup
Reasoning
The author wanted a boring but reliable setup, and says he will work on threading the dispatch and perhaps on moving to a different queue as the service grows, once the need arises.
Near: I went with a boring-but-reliable MySQL setup | Near: maybe switching to a different queue once
Keep messages on the server until each app has downloaded them, instead of relying on the push itself
pushover-2012-launch-stack#d2at corpus version 26a1b3a7e3dd
Chosen
Messages stay on the server and are deleted only once the app has downloaded all of them over HTTP and synced its local database. Synchronisation calls were added to the Rails API, the sending daemon was changed, and both the iOS and the Android app sync over SSL.
Section: January 21: iOS Changes my Plans
Rejected
Let Google's and Apple's push servers queue messages and store each alert on the device when it arrives. This was the author's first plan, which he calls naive. It could not work on iOS, where the app does not see every notification.
Near: My (naive) plan for Pushover was to | Near: completely different from how iOS handles APNS
What forced it
On iOS a notification that arrives while the app is not in the foreground is handled by the operating system and does not wake the app. The app gets it only if the user taps it; opened directly, the app cannot see it. So the app could not reliably receive and store every notification.
Near: a notification is only passed to an | Near: would not be able to reliably receive
What worked before
During development only, before the API existed, a simple script sent test messages straight to Google's C2DM servers for the Android app.
Serve the splash page as a static file from Apache unless the request carries a cookie
pushover-2012-launch-stack#d3at corpus version 26a1b3a7e3dd
Chosen
A deployment step fetches the splash page from Rails and saves it as a static file. A cookie-based mod_rewrite rule makes Apache serve that file when a request has no cookie and pass the request to Rails when it has one, so logged-in users still get their own view.
Section: February 28: Load Testing and Monitoring
Reasoning
The author wanted to be sure the Rails site would cope if it were announced somewhere popular, and expected most traffic to hit the static splash page.
Near: I wanted to be sure the Rails | Near: Since most traffic would be hitting the
Outcome
In load tests run with blitz.io before launch, not in production, the author reports the cached setup handled what he calls a respectable amount of traffic. No figure is given.
Monitor queue depth from the author's own network monitor and alert by text message, not through Pushover
pushover-2012-launch-stack#d4at corpus version 26a1b3a7e3dd
Chosen
An authenticated API call returns the number of messages in the queue. The author's network monitor polls that value and also polls the static and API sites for failures. For the Pushover components it falls back to text messages. SNMP hooks export messages received through the API per minute for graphing.
Section: February 28: Load Testing and Monitoring
Reasoning
The monitor was the reason Pushover was built, but once it monitored Pushover itself the author could not use Pushover to receive those alerts.