Live data from Hacker News

Phoenix WebSockets under a Microscope

zorbash.com

21–25 of 25 posts

Re: Phoenix WebSockets under a Microscope

#21
post #16
post #7

One of the highlights for Phoenix WebSockets came from the insights of one of my co-workers. I was having a problem where I only wanted to send websocket traffic up to 1 time every 3s (debounced essentially). I was struggling with this solution and came up with a hacky solution that would debounce on the event broadcast side (vs the socket side). This means it would be up to 1 time every N seconds per server. Co-work…

For some channels / topics I let the clients provide a `refresh_interval` parameter upon joining to tackle similar problems. I'm also curious to see your state machine, maybe it's something worth extracting to a middleware.

Put it up on a gist for HN https://gist.github.com/sb8244/e6884ad08d91de8c4aa5bf3241855...

Re: Phoenix WebSockets under a Microscope

#22
post #18

Phoenix creator here. Happy to answer any questions. This article does an excellent job diving into the underlying details of Phoenix channels and pubsub. For those that want a thousand foot view and are curious what makes Elixir and Phoenix unique compared to other solutions, think of Phoenix channels as trivial realtime communication that is distributed out of the box. With Elixir, processes (green threads) are loa…

Hey Chris! first of all thanks for your work on Phoenix and the excellent book about it. Phoenix solves many of the problems that held me away from Rails, much as I wanted to get good at it because I really liked Ruby. Secondly, thanks for your role and Jose's in the community. While I think the language and framework are most important, I feel that a certain 'culture' that pulled me into Ruby/Rails is also present i…

> It's more from a sense of confusion: Should I go for an umbrella app where Phoenix is just one app that communicates with others? Or something that is primarily a Phoenix app (as the book suggests, IIRC)?

I'm obviously not Chris, but this is something that's been discussed in the community and the way it's ended up is that you have an Elixir application, not a Phoenix application.

The way to treat it correctly in most cases is to have a Phoenix app be a part of an umbrella project where Phoenix handles the web component and very likely you'd have things like data and other services in one or more other applications inside the umbrella project.

If you're curious about Elixir and Phoenix I highly recommend http://elixirforum.com/ where you can find a great community for asking questions and learning more. Things like these come up every now and then and you get to be a part of the conversation and take everything in from both core members of the major projects to just other regular users.

Re: Phoenix WebSockets under a Microscope

#23
post #20

Earlier quoted context omitted.

I'd love to see how you accomplished this if you wouldn't mind sharing a gist or a post?

Here's a gist showing how it works (with anything secret removed): https://gist.github.com/sb8244/e6884ad08d91de8c4aa5bf3241855... This would be an interesting blog post, as the format for the state machine and logic behind it are quite fun.

Thanks for the gist. Drop a link here if you end up doing a blog post too - wouldn't want to miss it

Re: Phoenix WebSockets under a Microscope

#24
post #22
post #18

Earlier quoted context omitted.

Hey Chris! first of all thanks for your work on Phoenix and the excellent book about it. Phoenix solves many of the problems that held me away from Rails, much as I wanted to get good at it because I really liked Ruby. Secondly, thanks for your role and Jose's in the community. While I think the language and framework are most important, I feel that a certain 'culture' that pulled me into Ruby/Rails is also present i…

> It's more from a sense of confusion: Should I go for an umbrella app where Phoenix is just one app that communicates with others? Or something that is primarily a Phoenix app (as the book suggests, IIRC)? I'm obviously not Chris, but this is something that's been discussed in the community and the way it's ended up is that you have an Elixir application, not a Phoenix application. The way to treat it correctly in m…

Thing is, if the right way to do it is an umbrella project, why does Phoenix 'take charge' by default (mix phx.new)? There's other similar stuff I ran into that I can't think of right now, but it's an example of what causes this confusion.

I mean, I understand if the explicit goal of Phoenix is the provide an easy entry point for Rails devs, but I guess I'd like it if that was more explicit.

All that said, I'm being nitpicky/pedantic. I love both Phoenix and Elixir, and the ecosystem. And yes, I've been enjoying the elixir forums. Do you happen to know if there's some way to get a decent mobile version?

Re: Phoenix WebSockets under a Microscope

#25
post #24
post #22

Earlier quoted context omitted.

> It's more from a sense of confusion: Should I go for an umbrella app where Phoenix is just one app that communicates with others? Or something that is primarily a Phoenix app (as the book suggests, IIRC)? I'm obviously not Chris, but this is something that's been discussed in the community and the way it's ended up is that you have an Elixir application, not a Phoenix application. The way to treat it correctly in m…

Thing is, if the right way to do it is an umbrella project, why does Phoenix 'take charge' by default (mix phx.new)? There's other similar stuff I ran into that I can't think of right now, but it's an example of what causes this confusion. I mean, I understand if the explicit goal of Phoenix is the provide an easy entry point for Rails devs, but I guess I'd like it if that was more explicit. All that said, I'm being…

What do you mean by `mix phx.new` taking charge?

    $ mix new elixir_umbrella --umbrella
    $ cd elixir_umbrella/apps
    $ mix phx.new elixir_umbrella_web
This should work just fine and it means that this phoenix application is a sub-application in your umbrella project. Likely you'd do a `mix new elixir_umbrella_cool_service` to handle DB and service stuff that is more about business logic.

I can sort of see what you mean by Phoenix doing magic, because a lot of what you see on the surface looks like magic, but it's hard to really discuss these things when one can't pinpoint what the actual issue is.

On the idea of rails developers having an easy time, I don't really think it's that big a part of the concept, to be honest. A rails dev expecting rails is going to drown in BEAM/OTP things anyway provided he isn't making the same postgres + web-server applications without any real value from the BEAM, so I don't think the idea is to really cater to that kind of thing anyway. I'm not a rails dev, so I can't really say what their feeling is.

Post reply on HN