5 ms·
I wouldn't say I'm an expert in this area, but I do find Erlang/Elixir's actor model quite compelling.
by ricketycricket 8y ago
I wouldn't say I'm an expert in this area, but I do find Erlang/Elixir's actor model quite compelling.
- tormeh 8y agoThe big advantage of actors are that they are compatible with network loss. Erlang and Akka actors are network transparent. Local-only actors are missing the point, IMO.
- weberc2 8y agoI've not used an actor model--is there some router component that resolves the process to which a message needs to be sent? Is every send() operation a tuple of `(address, message)`? If so, presumably the router component decides whether there is a local actor or whether it needs to go out over the network?
- macintux 8y agoErlang runs atop its own VM that includes scheduler, routing services, etc. There are (at least) a couple of different ways to identify the recipient of a message: process ID (unique identifier for another actor) or Erlang's name service. The VM does indeed know whether the recipient is local; the sender typically neither knows nor cares, although the information is available if useful.
- amelius 8y agoHow do you make optimal use of a computer's memory hierarchy? Do messages allow structural sharing of data? Or is every message assumed to potentially go over the network, hence destroying opportunities for optimizations (e.g. think of the internal workings of a high-performance database engine).
- dnautics 8y agoIirc the idea here is that there are four very smart engineers working on the core that have taken care of that for you. Everything on top is quite battle tested.
- coldtea 8y ago>How do you make optimal use of a computer's memory hierarchy? Apparently more easily, with a faster time to market, and with less errors than alternative languages. E.g: https://blog.discordapp.com/scaling-elixir-f9b8e1e7c29b https://blog.discordapp.com/scaling-elixir-f9b8e1e7c29b https://www.wired.com/2015/09/whatsapp-serves-900-million-users-50-engineers/ https://www.wired.com/2015/09/whatsapp-serves-900-million-us... But the idea is not that you as the end programmer "make optimal use of a computer's memory hierarchy". It's that you write in a way that makes it easy for the runtime to ensure what you do is solid and correct and scalable -- and it's up for the runtime makers to make sure it makes optimal use of the computer's memory hierarchy. And it's also that you sacrifice some of that "optimal use", to get the "solid and correct and scalable" part.
- toast0 8y agoErlang does have a shared binary type, but the other types are simply copied. This is likely not space efficient, and it likely uses a lot more memory bandwidth. However, this allows for the garbage collection to be extremely simple. It may be pretty useful for NUMA systems as well; although, I'm not sure how well the VM manages that, it may be more potential than actual. Other actor systems may vary.
- dnautics 8y agoEvery 'proc' (like a thread) is id'd. You're responsible for finding the proc you want. Some procs are globally named and there can only be one. The VM translates proc IDs when you message pass across the network. If the proc dies, your message will fail, so you'll have to find the new target or drop what you were trying to do.
- toast0 8y agoIn Erlang, you do send a message to a destination. It also offers a way to register a name to a process, which you can build on to make whatever routing you need. Erlang/OTP ships with a module called pg2 that builds a synchronized group of processes in your distributed system, sending to the group will by default pick a local process over a remote process, or you can broadcast to all the processes.
- macintux 8y agoI'm fairly confident that Erlang's "actors" (the language authors didn't know about Hewitt's work at the time) were originally local-only, since the objective was robust processing on standalone network routers. I suspect the fact that asynchronous messaging turns out to be particularly well-suited to network communications was a happy accident. Anyway, I guess my point is that local-only actors can be useful, but I definitely agree that network transparency is a huge win.
- manigandham 8y agoIt's one advantage but not the only one. Actor systems can greatly increase throughput and scalability with easier code without complex synchronization. There are plenty of benefits running only on a single host.