1

I am currently creating an application with the Phoenix framework that uses channels for two way communication between a large number of mobile devices and a back-end service (obviously Phoenix based).

I am intending to create a single topic for each device given that devices are defined by ID, for example device:2149, device:1234 etc.

I have the following socket:

defmodule Webservice.DeviceSocket do
  use Phoenix.Socket
  channel "device:*", Webservice.DeviceChannel
  transport :websocket, Phoenix.Transports.WebSocket

  def connect(_params, socket) do
    {:ok, socket}
  end

  def id(_socket), do: nil
end

and the following channel:

defmodule Webservice.DeviceChannel do
  use Phoenix.Channel

  def join("device:" <> device_id, _params, _socket) do
    # do some stuff
    {:ok, socket}
  end

  def handle_in("some_message", %{"data" => data }, socket) do
    # Do stuff
    {:noreply, socket}
  end
end

Now given that I expect a large number of devices to use this service say around 90000, this means that 90000 topics need to be managed.

Will a large number of topics result in some overhead that will hurt the application's performance?

Chedy2149
  • 2,821
  • 4
  • 33
  • 56

1 Answers1

1

According to this blog post, Phoenix can handle at least 2 million websocket connections, but of course that assumes your machine is beefy enough. 90,000 should be a breeze.

Jesse Shieh
  • 4,660
  • 5
  • 34
  • 49