# Elixir/Phoenix Channel based chat application

**URL:** <https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984>\
**Category:** Questions\
**Tags:** phoenix, kubernetes, channel\
**Created:** [March 21, 2020, 6:59pm UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984 "2020-03-21T18:59:34Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![meraj\_enigma](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/meraj_enigma/32/38308_2.png) [@meraj\_enigma](https://forum.elixirforum.com/u/meraj_enigma)\
**Post date:** [March 21, 2020, 6:59pm UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984/1 "2020-03-21T18:59:34Z")

</div>

Hello,

I am currently investigating into writing a real time chat application in Elixir/Phoenix. I have a few queries before I jump into choosing a particular technology. Please see and answer my below queries -

1. Is WebSocket the standard for writing real time chat applications or can I use gRPC or is there any better transport mechanism?

2. How does Elixir/Phoenix Channel compares to other technologies or services like

3. If I decide to go with Elixir/Phoenix Channel, how can I run multiple instances of chat application on Kubernetes pods? Can someone points me to any document/article on this deployment part?

4. Is there any hidden problem using WebSocket with multiple instances of chat applications that I should know about - like security/stability/scalability/performance?

Awaiting some response.

Thanks,  
-Meraj

---

<div class="post-metadata">

**Author:** ![meraj\_enigma](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/meraj_enigma/32/38308_2.png) [@meraj\_enigma](https://forum.elixirforum.com/u/meraj_enigma)\
**Post date:** [March 22, 2020, 10:42pm UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984/2 "2020-03-22T22:42:41Z")

</div>

Came across this article - [WebSockets, caution required!](https://samsaffron.com/archive/2015/12/29/websockets-caution-required)

Even though a bit old would like to know where WebSockets in general but Phoenix Channels in particular stands with respect to the views expressed in above link.

Thanks!

---

<div class="post-metadata">

**Author:** ![kokolegorille](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kokolegorille/32/4784_2.png) [@kokolegorille](https://forum.elixirforum.com/u/kokolegorille)\
**Post date:** [March 22, 2020, 11:15pm UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984/3 "2020-03-22T23:15:31Z")

</div>

Websocket is one of the reason why I started Phoenix, coming from Rails…

1 If You use Phoenix, it might… but You can use other protocol  
2. Firestore. Pusher. Anycable are all external services. Actioncable… Phoenix channel, hmmm, cannot be compared  
3. Distribution is one aspect of the BEAM, but it’s not easy to setup  
4. Websocket is just the transport

Sorry to tell, but a chat app is just the hello world application in Phoenix. If Rails promotion video is about building a blog in 15 minutes, Phoenix one could be how to build a chat in 15 minutes.

Websocket is just the transport, but Elixir has building blocks for chat application.

You should really try to build one. And You will see it’s easy because of the tools the BEAM provides.

There was a lecture about building a chat in Erlang before Phoenix even existed, unfortunately it is outdated now.

[https://pragprog.com/screencast/v-kserl/erlang-in-practice](https://pragprog.com/screencast/v-kserl/erlang-in-practice)

The article You posted is about Ruby…

Update: I guess You can make it in less than 15 minutes… 🙂

> **[Chat Room in 8 Minutes - ElixirCasts](https://elixircasts.io/chat-room-in-8-minutes)**
>
> One of the great features of Phoenix is how easily it allows developers to include realtime functionality in applications. In this episode we'll use Channels to build a simple chat application in 8 minutes.

---

<div class="post-metadata">

**Author:** ![meraj\_enigma](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/meraj_enigma/32/38308_2.png) [@meraj\_enigma](https://forum.elixirforum.com/u/meraj_enigma)\
**Post date:** [March 22, 2020, 11:54pm UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984/4 "2020-03-22T23:54:29Z")

</div>

Hi @kokolegorille, thanks for your reply.

Regarding point 3 - I have come across the below articles -

> **[Distributed Phoenix Chat using Redis PubSub](https://www.poeticoding.com/distributed-phoenix-chat-using-redis-pubsub/)**
>
> In this article we'll see how to scale horizontally the Phoenix Chat app, using Redis and a Phoenix PubSub adapter.

> **[Distributed Phoenix Chat with PubSub PG2 adapter](https://www.poeticoding.com/distributed-phoenix-chat-with-pubsub-pg2-adapter/)**
>
> How to cluster Phoenix Chat nodes, using distributed Elixir. We see how pg2﻿ works and inspect how Phoenix efficiently broadcasts the messages in a distributed chat app.

> **[Connecting Elixir Nodes with libcluster, locally and on Kubernetes](https://www.poeticoding.com/connecting-elixir-nodes-with-libcluster-locally-and-on-kubernetes/)**
>
> We are going to see how to cluster Elixir and Phoenix nodes with libcluster, locally and on Kubernetes using containers.

Looks like using Redis Pub/Sub it’s not that complicated to setup. However, using PG2 adapter can be a bit complicated.

Thanks.

---

<div class="post-metadata">

**Author:** ![kokolegorille](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/kokolegorille/32/4784_2.png) [@kokolegorille](https://forum.elixirforum.com/u/kokolegorille)\
**Post date:** [March 23, 2020, 12:09am UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984/5 "2020-03-23T00:09:26Z")

</div>

These posts have been made by @alvises 🙂

---

<div class="post-metadata">

**Author:** ![meraj\_enigma](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/meraj_enigma/32/38308_2.png) [@meraj\_enigma](https://forum.elixirforum.com/u/meraj_enigma)\
**Post date:** [March 23, 2020, 12:20am UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984/6 "2020-03-23T00:20:56Z")

</div>

Thanks for the great articles @alvises

---

<div class="post-metadata">

**Author:** ![sb8244](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/sb8244/32/18642_2.png) [@sb8244](https://forum.elixirforum.com/u/sb8244)\
**Post date:** [March 23, 2020, 12:56am UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984/7 "2020-03-23T00:56:36Z")

</div>

WebSocket is a great transport mechanism and is what I’d recommend generally across the board today. Phoenix has its own protocol on top of WebSockets, but you _could_ implement something like gRPC messages if you wanted. I have never needed to do that.

Redis PubSub works great, but I wouldn’t shy away from the out-of-the-box pg implementation. It’s really not bad to setup in Kubernetes.

There can be lots of caveats with any technology, WebSocket included. Real-Time Phoenix tries to capture those gotchas as much as possible.

---

<div class="post-metadata">

**Author:** ![meraj\_enigma](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/meraj_enigma/32/38308_2.png) [@meraj\_enigma](https://forum.elixirforum.com/u/meraj_enigma)\
**Post date:** [March 23, 2020, 1:25am UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984/8 "2020-03-23T01:25:42Z")

</div>

Thanks @sb8244. I agree with you. I will try to read your book 🙂

---

<div class="post-metadata">

**Author:** ![alvises](https://forum.elixirforum.com/user_avatar/forum.elixirforum.com/alvises/32/2247_2.png) [@alvises](https://forum.elixirforum.com/u/alvises)\
**Post date:** [March 26, 2020, 7:27pm UTC](https://forum.elixirforum.com/t/elixir-phoenix-channel-based-chat-application/29984/9 "2020-03-26T19:27:06Z")

</div>

> [@meraj\_enigma](#):
>
> Looks like using Redis Pub/Sub it’s not that complicated to setup. However, using PG2 adapter can be a bit complicated.

I’d suggest to go for, at the beginning, with the default PG2 adapter avoiding to maintain a redis server as well.
