Why use Pusher?
Phil Leggetter
Sun May 11 2025
Introduction
Agenda - Why use Pusher?
- What is Pusher?
- What can you build with Pusher?
- Business Benefits Overview
- Tech Example - Polling v Pusher
- Any other questions?
* Why use Pusher? The whole purpose of the talk. Why it makes sense and it's awesome!
What is Pusher?
-
Cloud hosted scalable IaaS/SaaS
-
Realtime messaging service
-
Cross-platform support
-
HTML5 WebSocket powered!
-
Server & Client libraries
-
Awesome community of users
* It's in the cloud - normally works on it's own. Applause from sales/marketing :)
* Cross platform support: Web Browsers, Mobile, iPhone, iPad, Desktop
* Realtime messaging
* WebSockets are the standard for real-time bi-directional full duplex communication between a server and a client.
* Previous technology attempts have been hacks or workarounds. This stuff is now a standard and has massive backing from Google, Mozilla, Opera and even Microsoft have prototyped it and it *might* be in IE10. That said, it doesn't matter. There's fallback to Flash which covers 99% of all users according to Adobe.
* This all sounds great but what can you build with it?
What can you build with Pusher?
- Realtime Data updates and visualisations
- Push notifications & Activity Streams
- Chat
- Collaboration
- Social media reaction/integration
- Realtime Multiplayer Games
* Realtime data - financial data, sports data, betting odds, where instant updates matter
* Notifications: New tweets, facebook status updates, calendar appointment prompts, users coming online prompt
* Customer support chat, user to user chat (facebook chat)
* Collaboration: Google Draw, Docs, Spreadsheets
* Social media reaction/integration: Tweets, Facebook likes, Blog post notifications, Images from TwitPic or yFrog/ImageShack
* Games - whether simple gamification updates or true realtime html5 multiplayer games
* Again, awesome! But what does this matter? What are the business benefits?
Business Benefits Overview
-
It delivers the realtime web
-
User Engagement & User Experience
-
Pusher saves you Time & Money
-
It's awesome!
-
It's easy to integrate and use
* realtime web - it's not just a buzz term. It means the instant availability of data, and now the delivery of it. It means that data can be instantly used to build a much more engaging user experience.
* 2UEs - It's what keeps users on sites and using applications. Without it your website is just a brochure.
* Time & Money:
* installing and maintaining realtime infrastructure is getting easier but it's still not a cinch.
* The WebSockets protocol is stable but still enhancing. Pusher manages this for you.
* We are a Cloud service. We scale, so you don't have to.
* Realtime push-once. You publish a message once and it's instantly distributed to 1000's of connected clients. If you were having to do this yourself it would be resource intensive. Instead it costs just one REST API call.
* Awesome - It just is. Cool real-time updates, instant collaboration and it all working cross device has that wow factor. Whether it's just in your own product or even better if you want to WOW your clients. Just show off the tech!
* Easy - I'll show you.
Tech Example
Polling (Client)
- var lastUpdate = new Date();
- setInterval(function() {
- $.getJSON('ajax/get_update.php?since=' + lastUpdate, function(data) {
- var items = [];
-
- $.each(data, function(key, val) {
- items.push('<li id="' + key + '">' + val + '</li>');
- });
-
- $('#my_list').prepend(items);
- });
- lastUpdate = new Date();
- }, 10*1000);
Polling (Server) - Get the data
- <?php
- $update = $_POST['update'];
- $data = json_decode($update, true);
-
- $query = sprintf("INSERT INTO updates (key, value) VALUES ('%s', '%s')",
- mysql_real_escape_string($data['key'], $data['value']));
-
- $result = mysql_query($query);
-
- if($result) {
- header("HTTP/1.1 201 Created")
- }
- else { header("HTTP/1.1 418 I'm a teapot"); }
- ?>
Polling (Server) - handle the polling
- <?php // get_update.php
- $since = $_GET['since']; // assume format is correct
-
- $query = sprintf("SELECT updates WHERE created > '%s'",
- mysql_real_escape_string($since));
-
- $result = mysql_query($query); // assume no errors
-
- $rows = array();
- while($r = mysql_fetch_assoc($result)) {
- $rows[] = $r;
- }
- return json_encode($rows);
- ?>
* Every polling request = a database query
Polling Demo
Polling Resource Usage
Scenario
- Site average of 10,000 Users
- Over 1 Hour, with a 10 second polling interval
- Pages load + resources (HTML, CSS, JS, Images) = 50,000
- Poll requests per minute = (60 / 10) = 6
- Poll requests per hour = (6 * 60) = 360
- Poll requests site wide per hour = (360 * 10,000) = 3,600,000.
- Total: 3.65 Million requests
Can your server handle this?
* You can scale yourself but this takes time to set up and incurs recurring costs
Let's make it realtime!
Less Code
-
Faster feature development
-
Cleaner code / reduced complexity
-
Decreases the chances of errors and bugs
-
Reduced maintenance
* Faster time to market for product
* Cleaner code = easier to understand
Pusher (Client)
- var pusher = new Pusher("APP_KEY");
- var channel = pusher.subscribe('my-channel');
- channel.bind('my-event', function(data) {
- var items = [];
- $.each(data, function(key, val) {
- items.push('<li id="' + key + '">' + val + '</li>');
- });
-
- $('#my_list').prepend(items);
- });
* Ok, only a few lines difference but. Other than it being a bit cleaner there's no big difference.
* the pusher object will only be created once.
* the channel object may be the same.
Pusher (Server) - Get & Push
- <?php
- require('Pusher.php'); // new
-
- $update = $_POST['update'];
- $data = json_decode($update, true);
-
- $query = sprintf("INSERT INTO updates (key, value) VALUES ('%s', '%s')",
- mysql_real_escape_string($data['key'], $data['value']));
-
- $result = mysql_query($query);
-
- if($result) {
- $pusher = new Pusher($key, $secret, $app_id); // new
- $pusher->trigger('my-channel', 'my-event', $data); // new
-
- header("HTTP/1.1 201 Created")
- }
- else { header("HTTP/1.1 418 I'm a teapot"); }
- ?>
* We do see a difference on the server.
* completely lose the polling PHP file/controller action
* 3 lines to replace 14
* reduced complexity
* realtime updates
* guaranteed up to date information in the web browser
Pusher Demo
Pusher Resource Usage
Scenario
- Site average of 10,000 Users
- Over 1 Hour, no polling
- Pages load + resources (HTML, CSS, JS, Images) = 50,000.
- That's it! Total: 50,000
- 3.6 Million less than polling
* You can scale yourself but this takes time to set up and incurs recurring costs
Summary
- Pusher is an awesome WebSockets realtime messaging platform
- It can be used for a tonne of cool stuff
- It helps you build an essential engaging user experience
- It saves you a bucket load of time & money
- It stops your server falling over
- Where do you sign up? here
Thanks! Any questions?