SlideShare una empresa de Scribd logo
1 de 13
Descargar para leer sin conexión
Erlang
                     agile scaling - distributed cluster in 10 minutes




Sunday, February 22, 2009
Obsah

                    • Základní principy
                    • Úvod do syntaxe
                    • Distributed Erlang
                    • Demo: Distribuovaný PMAP algoritmus


Sunday, February 22, 2009
Erlang vs. Java




Sunday, February 22, 2009
Erlang vs. Java #2




Sunday, February 22, 2009
Základní principy
                    • Funkcionální jazyk - žádná podpora
                            OOP
                    • Procesy místo objektů
                    • Posílání zpráv místo threadů a sdílení
                            paměti
                    • Pattern matching místo přiřazování
                    • Podpora pro distribuované
                            programování
                    • Lehce exotická syntaxe
Sunday, February 22, 2009
Úvod do syntaxe
                    • Proměnné začinají velkým písmenem, lze přiřadit
                            pouze 1x

                    • Poslední výsledek je výstupem funkce
                    • Čárka odděluje výrazy a argumenty
                    • Středník odděluje klauzule (v rámcí jedné funkce)
                    • Tečka ukončuje funkci
                                -module(my_math).
                                -export([factorial/1]).
                                factorial(1) -> 1;
                                factorial(N) -> N * factorial(N - 1).


Sunday, February 22, 2009
Datové typy
                    • Integer - libovolná velikost
                    • Float (64 bit)
                    • Atom - podobné jako symboly v Ruby
                            •   true, false, ok, error


                    • Tuple - soubor prvků, pevná velikost
                            •   {1, 2, three, {3, 1}}


                    • List - soubor prvků, proměnná velikost
                            •   [1,2,3,4,5,[a,b,c]]


Sunday, February 22, 2009
Co chybí?
                    • String - pouze jako list integerů.
                            •   Res = lists:append([quot;Hello, quot;, quot;Erlangquot;, quot;!quot;]).
                                %%% Hello, Erlang!


                    • Boolean - lze nahradit použitím atomů
                            •   if
                                  A == true -> ok;
                                  A == false -> not_ok
                                end.


                    • Hash - lze použít list tuplů
                            •   Hash = [{key1, value1}, {key2, value2}].
                                {value,{_,Value}} = lists:keysearch(key1,1,Hash).


Sunday, February 22, 2009
Distributed Erlang
                    • Systém se skládá z nodů
                            • každý node má své jméno
                            • procesy beží na nodech, každý má své PID
                            • předávání správ mezi procesy je transparentní
                              (nemusíme znát příslušný node)

                            • spojení mezi nody je automaticky udržované a
                              tranzitivní (A -> B, B -> C => A -> C)

                            • komunikace povolena mezi nody se stejným cookie
                            • každý node má seznam všech ostatních nodes().
Sunday, February 22, 2009
Jak to rozjet?

                            echo quot;TWRKJYJEQZGEBRITIFLSquot; > ~/.erlang.cookie
                            erl -sname node1
                            erl -sname node2
                            erl -sname node3
                            (node1@localhost)> net_adm:ping(node2@localhost)
                            (node2@localhost)> net_adm:ping(node3@localhost)
                            (node3@localhost)> nodes().
                            [node1@localhost, node2@localhost]




Sunday, February 22, 2009
Co s tím? DPMAP!
                    • Distribuovaný Paralelní MAP
                            • paralelní výpočet hodnot funkce pro sadu
                               parametrů probíhající na několika počítačích
                               současně

                    • Oproti DRuby automatická správa nodů
                            • není potřeba vědět nic o IP adresách a portech
                            • přidávání dalších nodů je triviální


Sunday, February 22, 2009
Jak to funguje?
               • 80 řádek kódu:
                    • zjisti seznam nodů, nastartuj na nich worker procesy
                    • procházej sekvenci parametrů a rozděluj na workery
                            •   toto se děje zasíláním zpráv worker procesům pode PID

                    • počkej na odpovědi
                    • ukonči procesy
                    • vypiš výsledek

Sunday, February 22, 2009
DEMO !
      pmap(Fun, List) when is_function(Fun), is_list(List) ->
          Master = self(),
          Workers = lists:map(fun (Node) ->
                              proc_lib:spawn_link(Node, fun () ->
                                                        control(Master)
                                                        end)
                              end, [node() | nodes()]),
          Refs = distribute_tasks(Fun, List, Workers, Workers),
          lists:foreach(fun (Worker) ->
                            Worker ! stop
                        end,Workers),
          Res = gather_tasks(Refs),
          gather_workers(Workers),
          Res.




Sunday, February 22, 2009

Más contenido relacionado

Similar a Erlang: Agile Scaling

%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim CrontabsPaolo Negri
 
javascript teach
javascript teachjavascript teach
javascript teachguest3732fa
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_Whiteguest3732fa
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The JvmQConLondon2008
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvmdeimos
 
Rubish- A Quixotic Shell
Rubish- A Quixotic ShellRubish- A Quixotic Shell
Rubish- A Quixotic Shellguest3464d2
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2rubyMarc Chung
 
Presentation on Shared Memory Parallel Programming
Presentation on Shared Memory Parallel ProgrammingPresentation on Shared Memory Parallel Programming
Presentation on Shared Memory Parallel ProgrammingVengada Karthik Rangaraju
 
Dynomite at Erlang Factory
Dynomite at Erlang FactoryDynomite at Erlang Factory
Dynomite at Erlang Factorymoonpolysoft
 
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdfDatabase & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdfInSync2011
 
OS X에 놀러간 루비 이야기
OS X에 놀러간 루비 이야기OS X에 놀러간 루비 이야기
OS X에 놀러간 루비 이야기byblue
 
Twisted presentation & Jamendo usecases
Twisted presentation & Jamendo usecasesTwisted presentation & Jamendo usecases
Twisted presentation & Jamendo usecasesSylvain Zimmer
 
Big Data for Mobile
Big Data for MobileBig Data for Mobile
Big Data for MobileBugSense
 
MapReduce: teoria e prática
MapReduce: teoria e práticaMapReduce: teoria e prática
MapReduce: teoria e práticaPET Computação
 

Similar a Erlang: Agile Scaling (20)

%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
%w(map reduce).first - A Tale About Rabbits, Latency, and Slim Crontabs
 
javascript teach
javascript teachjavascript teach
javascript teach
 
JSBootcamp_White
JSBootcamp_WhiteJSBootcamp_White
JSBootcamp_White
 
J Ruby Power On The Jvm
J Ruby Power On The JvmJ Ruby Power On The Jvm
J Ruby Power On The Jvm
 
Ola Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The JvmOla Bini J Ruby Power On The Jvm
Ola Bini J Ruby Power On The Jvm
 
Ndp Slides
Ndp SlidesNdp Slides
Ndp Slides
 
Better code in JavaScript
Better code in JavaScriptBetter code in JavaScript
Better code in JavaScript
 
Rubish- A Quixotic Shell
Rubish- A Quixotic ShellRubish- A Quixotic Shell
Rubish- A Quixotic Shell
 
Hacking with ruby2ruby
Hacking with ruby2rubyHacking with ruby2ruby
Hacking with ruby2ruby
 
Presentation on Shared Memory Parallel Programming
Presentation on Shared Memory Parallel ProgrammingPresentation on Shared Memory Parallel Programming
Presentation on Shared Memory Parallel Programming
 
Dynomite at Erlang Factory
Dynomite at Erlang FactoryDynomite at Erlang Factory
Dynomite at Erlang Factory
 
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdfDatabase & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
Database & Technology 1 _ Tom Kyte _ Efficient PL SQL - Why and How to Use.pdf
 
OpenLogic
OpenLogicOpenLogic
OpenLogic
 
2 P Seminar
2 P Seminar2 P Seminar
2 P Seminar
 
OS X에 놀러간 루비 이야기
OS X에 놀러간 루비 이야기OS X에 놀러간 루비 이야기
OS X에 놀러간 루비 이야기
 
Twisted presentation & Jamendo usecases
Twisted presentation & Jamendo usecasesTwisted presentation & Jamendo usecases
Twisted presentation & Jamendo usecases
 
Egearmand: an Erlang Gearman daemon
Egearmand: an Erlang Gearman daemonEgearmand: an Erlang Gearman daemon
Egearmand: an Erlang Gearman daemon
 
Practical Groovy DSL
Practical Groovy DSLPractical Groovy DSL
Practical Groovy DSL
 
Big Data for Mobile
Big Data for MobileBig Data for Mobile
Big Data for Mobile
 
MapReduce: teoria e prática
MapReduce: teoria e práticaMapReduce: teoria e prática
MapReduce: teoria e prática
 

Más de Tomáš Holas

Gwt frameworky GXT + UJORM
Gwt frameworky GXT + UJORMGwt frameworky GXT + UJORM
Gwt frameworky GXT + UJORMTomáš Holas
 
Ondra Kučera: Otevřený web a jeho současný stav
Ondra Kučera: Otevřený web a jeho současný stavOndra Kučera: Otevřený web a jeho současný stav
Ondra Kučera: Otevřený web a jeho současný stavTomáš Holas
 
CZNIC: Správa internetu, routing a IPv6
CZNIC: Správa internetu, routing a IPv6CZNIC: Správa internetu, routing a IPv6
CZNIC: Správa internetu, routing a IPv6Tomáš Holas
 
Google App Engine - exploiting limitations
Google App Engine - exploiting limitationsGoogle App Engine - exploiting limitations
Google App Engine - exploiting limitationsTomáš Holas
 

Más de Tomáš Holas (9)

Gwt frameworky GXT + UJORM
Gwt frameworky GXT + UJORMGwt frameworky GXT + UJORM
Gwt frameworky GXT + UJORM
 
Úvod do OOP
Úvod do OOPÚvod do OOP
Úvod do OOP
 
Ondra Kučera: Otevřený web a jeho současný stav
Ondra Kučera: Otevřený web a jeho současný stavOndra Kučera: Otevřený web a jeho současný stav
Ondra Kučera: Otevřený web a jeho současný stav
 
Django
DjangoDjango
Django
 
Základy GWT
Základy GWTZáklady GWT
Základy GWT
 
Úvod do rails
Úvod do railsÚvod do rails
Úvod do rails
 
CZNIC: Správa internetu, routing a IPv6
CZNIC: Správa internetu, routing a IPv6CZNIC: Správa internetu, routing a IPv6
CZNIC: Správa internetu, routing a IPv6
 
Google App Engine - exploiting limitations
Google App Engine - exploiting limitationsGoogle App Engine - exploiting limitations
Google App Engine - exploiting limitations
 
Google App Engine
Google App EngineGoogle App Engine
Google App Engine
 

Último

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUK Journal
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherRemote DBA Services
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Scriptwesley chun
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfhans926745
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdfTech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 

Erlang: Agile Scaling

  • 1. Erlang agile scaling - distributed cluster in 10 minutes Sunday, February 22, 2009
  • 2. Obsah • Základní principy • Úvod do syntaxe • Distributed Erlang • Demo: Distribuovaný PMAP algoritmus Sunday, February 22, 2009
  • 3. Erlang vs. Java Sunday, February 22, 2009
  • 4. Erlang vs. Java #2 Sunday, February 22, 2009
  • 5. Základní principy • Funkcionální jazyk - žádná podpora OOP • Procesy místo objektů • Posílání zpráv místo threadů a sdílení paměti • Pattern matching místo přiřazování • Podpora pro distribuované programování • Lehce exotická syntaxe Sunday, February 22, 2009
  • 6. Úvod do syntaxe • Proměnné začinají velkým písmenem, lze přiřadit pouze 1x • Poslední výsledek je výstupem funkce • Čárka odděluje výrazy a argumenty • Středník odděluje klauzule (v rámcí jedné funkce) • Tečka ukončuje funkci -module(my_math). -export([factorial/1]). factorial(1) -> 1; factorial(N) -> N * factorial(N - 1). Sunday, February 22, 2009
  • 7. Datové typy • Integer - libovolná velikost • Float (64 bit) • Atom - podobné jako symboly v Ruby • true, false, ok, error • Tuple - soubor prvků, pevná velikost • {1, 2, three, {3, 1}} • List - soubor prvků, proměnná velikost • [1,2,3,4,5,[a,b,c]] Sunday, February 22, 2009
  • 8. Co chybí? • String - pouze jako list integerů. • Res = lists:append([quot;Hello, quot;, quot;Erlangquot;, quot;!quot;]). %%% Hello, Erlang! • Boolean - lze nahradit použitím atomů • if A == true -> ok; A == false -> not_ok end. • Hash - lze použít list tuplů • Hash = [{key1, value1}, {key2, value2}]. {value,{_,Value}} = lists:keysearch(key1,1,Hash). Sunday, February 22, 2009
  • 9. Distributed Erlang • Systém se skládá z nodů • každý node má své jméno • procesy beží na nodech, každý má své PID • předávání správ mezi procesy je transparentní (nemusíme znát příslušný node) • spojení mezi nody je automaticky udržované a tranzitivní (A -> B, B -> C => A -> C) • komunikace povolena mezi nody se stejným cookie • každý node má seznam všech ostatních nodes(). Sunday, February 22, 2009
  • 10. Jak to rozjet? echo quot;TWRKJYJEQZGEBRITIFLSquot; > ~/.erlang.cookie erl -sname node1 erl -sname node2 erl -sname node3 (node1@localhost)> net_adm:ping(node2@localhost) (node2@localhost)> net_adm:ping(node3@localhost) (node3@localhost)> nodes(). [node1@localhost, node2@localhost] Sunday, February 22, 2009
  • 11. Co s tím? DPMAP! • Distribuovaný Paralelní MAP • paralelní výpočet hodnot funkce pro sadu parametrů probíhající na několika počítačích současně • Oproti DRuby automatická správa nodů • není potřeba vědět nic o IP adresách a portech • přidávání dalších nodů je triviální Sunday, February 22, 2009
  • 12. Jak to funguje? • 80 řádek kódu: • zjisti seznam nodů, nastartuj na nich worker procesy • procházej sekvenci parametrů a rozděluj na workery • toto se děje zasíláním zpráv worker procesům pode PID • počkej na odpovědi • ukonči procesy • vypiš výsledek Sunday, February 22, 2009
  • 13. DEMO ! pmap(Fun, List) when is_function(Fun), is_list(List) -> Master = self(), Workers = lists:map(fun (Node) -> proc_lib:spawn_link(Node, fun () -> control(Master) end) end, [node() | nodes()]), Refs = distribute_tasks(Fun, List, Workers, Workers), lists:foreach(fun (Worker) -> Worker ! stop end,Workers), Res = gather_tasks(Refs), gather_workers(Workers), Res. Sunday, February 22, 2009