Cluster Configuration

What is a cluster?

  • A cluster represents the physical location of the servers that handle requests from your app.
  • Pusher’s default multi-tenant cluster is hosted in the United States us-east-1 region. We also offer a multi-tenant cluster in Europe eu-west-1, and in Asia ap-southeast-1 & ap-south-1. You can let us know which other regions we should add next by emailing feedback@pusher.com.

Why would I need this?

  • To achieve lower network latency.
    • Depending on your use case, having your Pusher app hosted close to its customers or your servers may help improve the latency when sending and receiving messages.
    • We recommend that you test on multiple clusters and pick the one that works best for your app.
  • To comply with data protection regulations.
    • European data protection regulations specify that personal user data should not leave the EU borders.
    • For this use-case, Pusher offers a cluster in eu-west-1, an AWS datacenter located in Ireland.

How do you configure the cluster option?

Where it says APP_CLUSTER you’ll need to insert the relevant cluster shortcode. Currently the clusters that we’ve got use the following shortcodes.

  • The default cluster, in us-east-1, has a shortcode of mt1. You currently don’t need to specify this as it’s assumed as the default, but there’s no harm in doing so.
  • The European cluster in eu-west-1 has a shortcode of eu.
  • The Asia Pacific cluster in ap-southeast-1 (Singapore) has a shortcode of ap1.
  • The Asia Pacific cluster in ap-south-1 (Mumbai) has a shortcode of ap2.

On the client-side:

var pusher = new Pusher("APP_KEY", {
  cluster: "APP_CLUSTER"
});
let options = PusherClientOptions(
    host: .cluster("eu")
)

let pusher = Pusher(key: "YOUR_APP_KEY", options: options)
pusher.connect()
OCAuthMethod *authMethod = [[OCAuthMethod alloc] initWithAuthEndpoint:@"https://your.authendpoint/pusher/auth"];
OCPusherHost *host = [[OCPusherHost alloc] initWithCluster:@"eu"];
PusherClientOptions *options = [[PusherClientOptions alloc]
                                initWithOcAuthMethod:authMethod
                                attemptToReturnJSONObject:YES
                                autoReconnect:YES
                                ocHost:host
                                port:nil
                                encrypted:YES];

Pusher *pusher = [[Pusher alloc] initWithAppKey:@"YOUR_APP_KEY" options:options];
[pusher connect];
#import <Pusher/Pusher.h>

self.client = [PTPusher pusherWithKey:@"APP_KEY" delegate:self cluster:@"APP_CLUSTER"];

[self.client connect];
import com.pusher.client.Pusher;

PusherOptions options = new PusherOptions();
options.setCluster("APP_CLUSTER");

Pusher pusher = new Pusher("APP_KEY", options);

pusher.connect();

On the server-side:

require 'pusher'

pusher_client = Pusher::Client.new(
  app_id: 'APP_ID',
  key: 'APP_KEY',
  secret: 'APP_SECRET',
  cluster: 'APP_CLUSTER'
);
require __DIR__ . '/vendor/autoload.php';

$pusher = new Pusher\Pusher(APP_KEY, APP_SECRET, APP_ID, array(
  'cluster' => 'APP_CLUSTER'
));
var Pusher = require('pusher');

var pusher = new Pusher({
  appId: 'APP_ID',
  key: 'APP_KEY',
  secret: 'APP_SECRET',
  cluster: 'APP_CLUSTER'
});
using PusherServer;
using System.Web.Mvc;
using System.Net;
using Your.Config;

public class HelloWorldController : Controller {
  [httpPost]
  public ActionResult HelloWorld() {
    var options = new PusherOptions();
    options.Cluster = Config.AppCluster;
    var pusher = new Pusher(Config.AppId, Config.AppKey, Config.AppSecret, options);
  }
}
from pusher import Pusher

pusher = Pusher(
  app_id=u'APP_ID',
  key=u'APP_KEY',
  secret=u'APP_SECRET',
  cluster=u'APP_CLUSTER'
)
package main

import "github.com/pusher/pusher-http-go"

func main(){
  client := pusher.Client{
    AppId: "APP_ID",
    Key: "APP_KEY",
    Secret: "APP_SECRET",
    Cluster: "APP_CLUSTER",
  }
}
Pusher pusher = new Pusher("APP_ID", "APP_KEY", "APP_SECRET");

pusher.setCluster("APP_CLUSTER");

Details

  • The cluster option is required if the Pusher app was created in a different cluster to us-east-1.
  • Setting the cluster option will change the host parameter of the Pusher library you are using. This happens only when the host option is not set, in which case, cluster is ignored.
  • For client libraries, the default host is ws.pusherapp.com (and sockjs.pusherapp.com for fallback transports). With cluster set, the host becomes ws-cluster.pusher.com (and sockjs-cluster.pusher.com respectively).
  • For server libraries, the default host is api.pusherapp.com. With cluster set, the host becomes api-cluster.pusher.com.

How to debug it?

  • First make sure your app is created in the intended cluster and that all the Pusher libraries you are using in your project are configured correctly.
  • Make sure your app makes requests to the correct endpoints. On the server-side, use a traffic sniffing tool like tcpdump. On the client-side, open your browser’s developer tools and inspect the network requests.
  • Contact support

Have you tried using the search to find what you’re after? If you still have a question then get in touch with us and let us help you out.