… | |
… | |
508 | snd $NODE, time => $myport, timereply => 1, 2; |
508 | snd $NODE, time => $myport, timereply => 1, 2; |
509 | # => snd $myport, timereply => 1, 2, <time> |
509 | # => snd $myport, timereply => 1, 2, <time> |
510 | |
510 | |
511 | =back |
511 | =back |
512 | |
512 | |
|
|
513 | =head1 AnyEvent::MP vs. Distributed Erlang |
|
|
514 | |
|
|
515 | AnyEvent::MP got lots of its ideas from distributed erlang (erlang node |
|
|
516 | == aemp node, erlang process == aemp port), so many of the documents and |
|
|
517 | programming techniques employed by erlang apply to AnyEvent::MP. Here is a |
|
|
518 | sample: |
|
|
519 | |
|
|
520 | http://www.erlang.se/doc/programming_rules.shtml |
|
|
521 | http://erlang.org/doc/getting_started/part_frame.html # chapters 3 and 4 |
|
|
522 | http://erlang.org/download/erlang-book-part1.pdf # chapters 5 and 6 |
|
|
523 | http://erlang.org/download/armstrong_thesis_2003.pdf # chapters 4 and 5 |
|
|
524 | |
|
|
525 | Despite the similarities, there are also some important differences: |
|
|
526 | |
|
|
527 | =over 4 |
|
|
528 | |
|
|
529 | =item * Node references contain the recipe on how to contact them. |
|
|
530 | |
|
|
531 | Erlang relies on special naming and DNS to work everywhere in the |
|
|
532 | same way. AEMP relies on each node knowing it's own address(es), with |
|
|
533 | convenience functionality. |
|
|
534 | |
|
|
535 | This means that AEMP requires a less tightly controlled environment at the |
|
|
536 | cost of longer node references and a slightly higher management overhead. |
|
|
537 | |
|
|
538 | =item * Erlang uses processes and a mailbox, AEMP does not queue. |
|
|
539 | |
|
|
540 | Erlang uses processes that selctively receive messages, and therefore |
|
|
541 | needs a queue. AEMP is event based, queuing messages would serve no useful |
|
|
542 | purpose. |
|
|
543 | |
|
|
544 | (But see L<Coro::MP> for a more erlang-like process model on top of AEMP). |
|
|
545 | |
|
|
546 | =item * Erlang sends are synchronous, AEMP sends are asynchronous. |
|
|
547 | |
|
|
548 | Sending messages in erlang is synchronous and blocks the process. AEMP |
|
|
549 | sends are immediate, connection establishment is handled in the |
|
|
550 | background. |
|
|
551 | |
|
|
552 | =item * Erlang can silently lose messages, AEMP cannot. |
|
|
553 | |
|
|
554 | Erlang makes few guarantees on messages delivery - messages can get lost |
|
|
555 | without any of the processes realising it (i.e. you send messages a, b, |
|
|
556 | and c, and the other side only receives messages a and c). |
|
|
557 | |
|
|
558 | AEMP guarantees correct ordering, and the guarantee that there are no |
|
|
559 | holes in the message sequence. |
|
|
560 | |
|
|
561 | =item * In erlang, processes can be declared dead and later be found to be |
|
|
562 | alive. |
|
|
563 | |
|
|
564 | In erlang it can happen that a monitored process is declared dead and |
|
|
565 | linked processes get killed, but later it turns out that the process is |
|
|
566 | still alive - and can receive messages. |
|
|
567 | |
|
|
568 | In AEMP, when port monitoring detects a port as dead, then that port will |
|
|
569 | eventually be killed - it cannot happen that a node detects a port as dead |
|
|
570 | and then later sends messages to it, finding it is still alive. |
|
|
571 | |
|
|
572 | =item * Erlang can send messages to the wrong port, AEMP does not. |
|
|
573 | |
|
|
574 | In erlang it is quite possible that a node that restarts reuses a process |
|
|
575 | ID known to other nodes for a completely different process, causing |
|
|
576 | messages destined for that process to end up in an unrelated process. |
|
|
577 | |
|
|
578 | AEMP never reuses port IDs, so old messages or old port IDs floating |
|
|
579 | around in the network will not be sent to an unrelated port. |
|
|
580 | |
|
|
581 | =item * Erlang uses unprotected connections, AEMP uses secure |
|
|
582 | authentication and can use TLS. |
|
|
583 | |
|
|
584 | AEMP can use a proven protocol - SSL/TLS - to protect connections and |
|
|
585 | securely authenticate nodes. |
|
|
586 | |
|
|
587 | =back |
|
|
588 | |
513 | =head1 SEE ALSO |
589 | =head1 SEE ALSO |
514 | |
590 | |
515 | L<AnyEvent>. |
591 | L<AnyEvent>. |
516 | |
592 | |
517 | =head1 AUTHOR |
593 | =head1 AUTHOR |