TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Elixir multiple processes: Basics

131 pointsby ck3gover 7 years ago

3 comments

sbuttgereitover 7 years ago
I&#x27;m in the process of learning Elixir and the observation I&#x27;m about to make may be completely off-base. With that said...<p>Seems like the section on &quot;When to use processes&quot; is selling processes short a bit. Certain kinds of state management would seem to call for processes to either manage or even hold state... but processes (as I understand them) are also key in designing for reliability. So I would think I may well want to organize my code relative to processes as I&#x27;m also figuring out the supervision trees and various failure scenarios. And yes, concurrency issues as well. If I&#x27;m wrong on this, I&#x27;d be happy to be set straight.<p>Anyway, yes, the section I speak of does get to some of the other parts of what I mention, but the emphasis on state management seems to distort and unbalance the view of what you might want as a process.<p>[edited a touch for clarity]
评论 #15948595 未加载
评论 #15950244 未加载
评论 #15954199 未加载
nickjjover 7 years ago
Maybe I&#x27;m thinking about this incorrectly but when it comes to web application development and concurrency, the things I would typically want to run in a separate process are very important tasks.<p>For example, let&#x27;s say you&#x27;re sending emails out.<p>In Rails, Flask, etc. you would typically offload this to a background worker like Sidekiq or Celery. These are dedicated libraries that run in their own process and handle job processing.<p>Both tools allow you to see if that job was successful or failed and deals with retries. They also use Redis as a back-end so your state persists outside of the application code.<p>If you just willynilly spawn a process and start sending stuff through it, how do you ensure everything works as expected and what happens to all of your state if the Erlang VM goes down?<p>I love the idea of doing this, but in real world practice, it sounds like you would still need the Elixir equiv. of Sidekiq &#x2F; Celery to handle ensuring these spawned tasks are trackable, right?
评论 #15951227 未加载
评论 #15951483 未加载
redshirtover 7 years ago
Very cool. I&#x27;m adding this to my list of easy concurrency tools. The main thing I like is the statelessness. That&#x27;s where most people screw up parallel programs.<p>Seems like there are many languages&#x2F;libraries trying to make concurrency easier to implement in practice. Most notably for C++ (my fav since I have to use it for most of my work projects): Intel TBB (definitely the go to for most things), RaftLib (saw at C++Now last year) is probably the easiest to understand (same theme as this post, super easy concurrency for c++). Even Java seems to make concurrency rather easy with it&#x27;s thread pools and relatively strait-forward synchronized sections.
评论 #15951954 未加载
评论 #15951074 未加载