Skip to main content

Faye - real time messaging

Sends realtime messages to the logged in users. Generally reports things like notifications.

What is Faye?

Faye is a websockets implementation that we run on notifications.pixwel.com. The UI subscribes to endpoints - e.g. a user’s browser may subscribe to notifications.pixwel.com/staging/faye/{my user id} to get notifications for a given user. This endpoint does not have to exist at the time of subscription, but if any messages get pushed to that endpoint, the user’s browser will pick them up.

Where does Faye run?

  • On development, it runs locally
  • On all other environments, it runs on notifications.pixwel.com with endpoints for the various environments.

Testing Faye

  • Open Chrome and open the web sockets tab of Chrome tools
  • Log in as User A
  • Assert that a web sockets connection is made to Faye
  • In an incognito tab, log in as User A and then find User B and click the ‘impersonate’ button for that user
  • As User B, share some assets to User A
  • As User A, click Notifications in the grey bar and assert that the new share is in there

Infrastructure

notifications.pixwel.com is provisioned through the Ansible (details below).

AWS setup

NameTypePurpose
vpc_notificationsVirtual private clusterPrivate subcloud for notifications.
subnet_notifications_bSubnetNet in VPC for allocating IPs and containing the cluster.
sg_notifications_vpc_defaultSecurity groupDefine ports 443 and 22 as the only accessible ports.
igw_notificationsInternet gatewayEverything in vpc_notifications must talk through this internet interface
route_notificationsRouting tableDefines what routes can happen in the VPC. Ties the gateway to the subnet.
<varies>EC2 nodeHosts Faye. Installed as an Upstart job.

Replacing the notifications server

If the notifications server drifts significantly, or is somehow compromised or lost, you can stand up a new one:
cd ansible
./stand_up_new_notifications_server.sh
This follows our standard immutable infrastructure approach (sort of). It uses the radify-base-box and simply runs the ansible/stand_up_new_notifications_server.yaml playbook. It does not use a load balancer because load balancers do not support web sockets. Once the script has completed, you will need to follow a few manual steps to update DNS.
Back to docs index | Next page in recommended reading order >>