Remix.run Logo
sevenzero 3 hours ago

Yea I've posted there twice as far as I remember. You will absolutely get help, whether you understand the answers is a whole different story.

Elixirs community is great. Its just hard to learn because it's not yet widely adopted, there are no (non senior) roles for it and it's a lot of work understanding all the BEAM concepts. A thing just being interesting isn't enough motivation for me to learn, I need a bigger goal but with Elixir there do not seem to be any.

My last experience with it was building something with Phoenix Liveview until I noticed how easily you can hijack the websocket and just spam random commands to your server or temper with payloads (with regular webapps ive built i never had this issue). Which made me quit that project.

pdimitar 3 hours ago | parent | next [-]

Fair. If you have this friction then it's not worth pursuing.

One thing that really helped me pick it up was saying YOLO and rewriting one part of the business stack from Ruby on Rails to Elixir. It taught me quickly and well.

The official guides are also great and IMO you can get through them all without a rush in two weekends. But again, if you don't want to then don't.

You can also try asking right here in this HN thread. Maybe I or others would be willing to give you a more detailed response.

sevenzero 3 hours ago | parent [-]

When building I couldn't get "what if I have ghost processes", "what if I spawn too many processes", "what if this architecture is bad compared to...", "when to kill processes", "whats the correct restart strategy for this" out of my head... It's so confusing to build for the BEAM that I ultimately gave up on it.

pdimitar 3 hours ago | parent | next [-]

Ah, true. You are right this assumes some familiarity. Definitely a gap.

Check this out: https://www.theerlangelist.com/article/spawn_or_not

Written by one of the very best Elixir mentors. I believe it will dispel most (hopefully all) of your doubts and clear things up.

macintux 2 hours ago | parent [-]

I'd also suggest skimming this free ebook: https://erlang-in-anger.com

toast0 an hour ago | parent | prev [-]

> "what if I have ghost processes",

I'm not sure what a ghost process is? I guess something that's living beyond its usefulness / isn't supervised, etc? ... I don't speak Elixir, but you can do the equivalent of this Erlang to see everything on the node:

    rp([{X, erlang:process_info(X)} || X <- erlang:processes()]).
Then you'll know what's going on. Caveat: if you have a lot of processes, that's going to use a bunch of memory; for production you probably don't want to use erlang:process_info/2 with specific items instead of the default items. And you might don't want to output something for all the processes if you have a lot of "normal" processes that won't need to be listed.

> "what if I spawn too many processes",

The default limit is 1,048,576, if you want to have more, you can add +P X to the erl command line with a bigger limit? Have your monitoring alert you when you're at ~ 80% of the limit.

> "what if this architecture is bad compared to...",

This probably addresses the real question of your too many process question. If your architecture is bad or if you spawn more processes than a good architecture would, your performance will be bad. If your architecture is really bad, you'll have a hard time solving the problems you're trying to solve. Future you will look upon your system and despair; you may also despair in the present...

Eh, you're going to make bad architecture. BEAM won't solve all your problems. But, if you've got problems it can solve, IMHO, it can be a very nice way to solve them.

> "when to kill processes",

Kill processes (or let them crash) when they misbehave. Kill them (or let them exit normally) when they've done their work and they don't have anything else to do or wait for. When you spawn a process, you'll often have a pretty good idea of the conditions that would lead to its death... Ex: if you spawn a process to handle a connection, it should probably die around the time that the connection ends. If you spawn a process to handle a request, it should probably die when the request is handled. If you spawn a process to listen for connections, it probably should die when you don't want to listen anymore. Etc.

> "whats the correct restart strategy for this"

Well... it depends. Almost never the default strategy. The default strategy is a big foot gun; at least it is for Erlang, maybe they changed it in Elixir. I need zero hands to count the number of times I actually wanted BEAM to stop because some supervised process failed 3 times in a small time frame; but it's happened to me a lot more times than that. For per connection or per request things, the appropriate strategy is not to restart at all; for other things, try to restart a few times quickly then maybe every minute or so is probably sufficient. You'll want some sort of alerting. And if the restart strategy isn't right, you can always console in and poke it.

ch4s3 3 hours ago | parent | prev [-]

> whether you understand the answers is a whole different story.

You can always ask follow up questions for clarification, people there are generally really friendly.