[erlang-questions] Workflow process model
Wed Oct 30 08:27:55 CET 2013
2013.10.29 20:02, Charles Irvine rašė:
> I’ve considered making each such workflow instance a process but I
> hesitate to do this since a process may have a relatively long
> lifetime and there might be a long duration between significant
> events. For example, a defect might not get fixed for weeks or months
> and a long time could elapse between the time the defect is reported
> and the time that someone starts working on it.
> A little nudge or two from folks more skilled than me at this would
> be much appreciated.
I (together with a few people in this mailing list) created a tool to
manage number portability database (when you migrate your phone number
from one operator to another, some entity has to mediate it) on national
scale. A single process is responsible for a single transaction, which
includes a range of numbers. Transactions can last from 1 day to years.
A process is a state machine which just sends messages to operators
according to some rules.
One transaction is an erlang process, which, if does not receive a
message for 60 minutes, hibernates. When you hibernate, you do not worry
about the number of processes. We also had distribution, so there was no
For recovery and audit purposes you can log every incoming/outgoing
message. That will let you reply all transactions and return to the
state before crash (we did it wrong way, but later realized that this
should have been done instead).
So in short, stick to the process model and, if you are worried about
number of them, hibernate. I just tried running 1M hibernated processes
on a 64bit laptop. Takes 866M residential memory. Of course, yours will
take more depending on size of your state. But still it's cheap.
More information about the erlang-questions