SlideShare una empresa de Scribd logo
1 de 37
ErLounge/SF Bay
     2010.1.12
Welcome
hello_world.erl
wello_horld.erl
wello_horld.erl
wello_horld.erl
CoTweet Robot: Task
CoTweet Robot: Task

• Pull updates from Twitter API:
 • n * 10,000 channels ( n is going up -- o/ )
CoTweet Robot: Task

  • Pull updates from Twitter API:
   • n * 10,000 channels ( n is going up -- o/ )

channel update req. 4 http requests on average

        = n million http requests / hr
CoTweet Robot: Task

• Pull updates from Twitter API:
 • n * 10,000 channels ( n is going up -- o/ )
• Minimize latency:
 • Ideally < 300s between updates
CoTweet Robot: Task

• Pull updates from Twitter API:
 • n * 10,000 channels ( n is going up -- o/ )
• Minimize latency (< 300s between updates)
• <blink>Survivable</blink> !
Primordial Ooze: Ruby




     Note: not a real robot
Primordial Ooze: Ruby
Primordial Ooze: Ruby




Like any tool, rails is great for some things...
Robot Evolution: I
Robot Evolution: I

• Main process: receive/after loop:
 service_loop() ->
    spawn(?MODULE, do_work, []),
    receive after SleepyTimeMS * 1000 -> ok end,
    service_loop().
Robot Evolution: I
• Main process: receive/after loop
 • Reads user info from database
 • For every N records ...
Robot Evolution: I
• Main process: receive/after loop
 • Reads user info from database
 • For every N records:
   • spawn() a worker to process bucket:
     • Retrieve updates from Twitter API
     • Insert into database (returning ID)
     • Insert (using ID) into memcached
spawn() responsibly.

• I <3 supervisors
• trap_exit + PID = spawn_link(M, F, [A]).
• {PID,Ref} = spawn_monitor(M,F,[A]).
Single Assignment != Stateless
Single Assignment != Stateless

• gen_server, gen_event, gen_fsm: State

 -record(State, {foo,bar}).

 handle_call({set_foo, V}, _From, State) ->
    {reply, State#state{ foo = V };
Single Assignment != Stateless
•   ets

    •   Many concurrent reads? No problem.




    start() ->
       ets:new(state, [named_table, public]).

    set_foo(V) ->
       ets:insert(state, {foo,V}).
Single Assignment != Stateless
•   ets

    •   Many concurrent reads? No problem.

    •   Many concurrent writes?

        •   May need to Serialize through a gen_server.

    handle_call({set_foo, V}, _From, State) ->
       ets:insert(state, {foo, V}),
       {reply, State};
Single Assignment != Stateless

• gen_server, gen_event, gen_fsm: State
• ets: app-wide
 • serialize writes through a gen_server
• mnesia: persistent
• process dictionary: put(K,V) / get(K)
 • Tiny, transient, process-level
 • (think: private):
Robot Evolution: II
Robot Evolution: II
• All state held in ets
• Robot comprises many ‘services:’
 • Feeder: poll db as needed, update ets
 • Scheduler: add tasks to work queue
   • Business logic:
      • even work load, limit resource(s)
 • Dispatcher: service queue for workers
Hm, our “workers” may block waiting for
 result(i.e., ID) of an insert from DB . . .
Hm, our “workers” may block waiting for
 result(i.e., ID) of an insert from DB . . .




  Needs more OTP.
Robot Evolution: III


• gen_event as simplest MUX ever
• no time for downtime: hot deployment
gen_event

• Extraordinarily easy to multiplex:
 • Create an event manager: gen_event
 • Add handlers
 • Fire an event
• Not just for logging . . .
Deployment

-module(my_app).
-export([reload_modules/0]).

-define(APP_MODS, [my_app, my_service]).

reload_modules() ->
    lists:map(fun(M) -> code:load_file(M) end,
               ?APP_MODS).




See: http://www.erlang.org/cgi-bin/ezmlm-cgi/4/36236
Open Source
                                    “Standing on the
                                shoulders of giants...”
                                                -- Bob Ippolito




S. Mestrom with K. Newby
Open Source
• plists (parallel list operations)
• lhttpc (much lighter than inets)
• rfc_4627 (utf8 JSON decoding)
• epgsql (PostGreSQL driver)
• erlang_twitter (Twitter API via xmerl)
• merle (erlang memcached adapter)
• mochi (congrats to MochiMedia!)
Thanks

• SocialMedia -- Ken Thom
• CoTweet
• You
ErLounge


• Grab another drink
• Share your stories

Más contenido relacionado

La actualidad más candente

La actualidad más candente (20)

CNIT 127 Ch 1: Before you Begin
CNIT 127 Ch 1: Before you BeginCNIT 127 Ch 1: Before you Begin
CNIT 127 Ch 1: Before you Begin
 
BOSH deploys distributed systems, and Diego runs any containers
BOSH deploys distributed systems, and Diego runs any containersBOSH deploys distributed systems, and Diego runs any containers
BOSH deploys distributed systems, and Diego runs any containers
 
Async programming and python
Async programming and pythonAsync programming and python
Async programming and python
 
0.5mln packets per second with Erlang
0.5mln packets per second with Erlang0.5mln packets per second with Erlang
0.5mln packets per second with Erlang
 
Lua and its Ecosystem
Lua and its EcosystemLua and its Ecosystem
Lua and its Ecosystem
 
CNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugsCNIT 127 Ch 4: Introduction to format string bugs
CNIT 127 Ch 4: Introduction to format string bugs
 
CNIT 127: Ch 3: Shellcode
CNIT 127: Ch 3: ShellcodeCNIT 127: Ch 3: Shellcode
CNIT 127: Ch 3: Shellcode
 
System Updates with Ansible - Ansible Brno #1 - Vincent van Scherpenseel
System Updates with Ansible - Ansible Brno #1 - Vincent van ScherpenseelSystem Updates with Ansible - Ansible Brno #1 - Vincent van Scherpenseel
System Updates with Ansible - Ansible Brno #1 - Vincent van Scherpenseel
 
Fluentd v1 and Roadmap
Fluentd v1 and RoadmapFluentd v1 and Roadmap
Fluentd v1 and Roadmap
 
127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux127 Ch 2: Stack overflows on Linux
127 Ch 2: Stack overflows on Linux
 
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
CNIT 127 Ch 4: Introduction to format string bugs (rev. 2-9-17)
 
Fluentd Hacking Guide at RubyKaigi 2014
Fluentd Hacking Guide at RubyKaigi 2014Fluentd Hacking Guide at RubyKaigi 2014
Fluentd Hacking Guide at RubyKaigi 2014
 
CNIT 127: Ch 2: Stack Overflows in Linux
CNIT 127: Ch 2: Stack Overflows in LinuxCNIT 127: Ch 2: Stack Overflows in Linux
CNIT 127: Ch 2: Stack Overflows in Linux
 
CNIT 127 Ch Ch 1: Before you Begin
CNIT 127 Ch Ch 1: Before you BeginCNIT 127 Ch Ch 1: Before you Begin
CNIT 127 Ch Ch 1: Before you Begin
 
Java プログラマーのための Swift 入門 #中央線Meetup
Java プログラマーのための Swift 入門 #中央線MeetupJava プログラマーのための Swift 入門 #中央線Meetup
Java プログラマーのための Swift 入門 #中央線Meetup
 
Introduction to .NET
Introduction to .NETIntroduction to .NET
Introduction to .NET
 
Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016Treasure Data Summer Internship 2016
Treasure Data Summer Internship 2016
 
CNIT 127 Ch 3: Shellcode
CNIT 127 Ch 3: ShellcodeCNIT 127 Ch 3: Shellcode
CNIT 127 Ch 3: Shellcode
 
The Stack and Buffer Overflows
The Stack and Buffer OverflowsThe Stack and Buffer Overflows
The Stack and Buffer Overflows
 
How do event loops work in Python?
How do event loops work in Python?How do event loops work in Python?
How do event loops work in Python?
 

Destacado (6)

Lunch2.0 - Other presentation tools
Lunch2.0 - Other presentation toolsLunch2.0 - Other presentation tools
Lunch2.0 - Other presentation tools
 
April 30, 2014 LaMonte
April 30, 2014 LaMonteApril 30, 2014 LaMonte
April 30, 2014 LaMonte
 
Vriosimulationstrategyedited
VriosimulationstrategyeditedVriosimulationstrategyedited
Vriosimulationstrategyedited
 
Embracing Social Media Part 3
Embracing Social Media Part 3Embracing Social Media Part 3
Embracing Social Media Part 3
 
Kdssc Company Presentation 2009
Kdssc  Company Presentation   2009Kdssc  Company Presentation   2009
Kdssc Company Presentation 2009
 
C. Ononaiwu - CARICOM Agreements On Investment - Treaty Shopping & Consistenc...
C. Ononaiwu - CARICOM Agreements On Investment - Treaty Shopping & Consistenc...C. Ononaiwu - CARICOM Agreements On Investment - Treaty Shopping & Consistenc...
C. Ononaiwu - CARICOM Agreements On Investment - Treaty Shopping & Consistenc...
 

Similar a ErLounge SF/Bay: 2010.01.12 Christian Westbrook / CoTweet

Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
Serge Stinckwich
 
Deep Learning for Unified Personalized Search and Recommendations - Jake Mann...
Deep Learning for Unified Personalized Search and Recommendations - Jake Mann...Deep Learning for Unified Personalized Search and Recommendations - Jake Mann...
Deep Learning for Unified Personalized Search and Recommendations - Jake Mann...
Lucidworks
 
Format of first slide for main PPT-GIT.pptx
Format of first slide for main PPT-GIT.pptxFormat of first slide for main PPT-GIT.pptx
Format of first slide for main PPT-GIT.pptx
MOHAMMADANISH12
 
Distributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromqDistributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromq
Ruben Tan
 

Similar a ErLounge SF/Bay: 2010.01.12 Christian Westbrook / CoTweet (20)

System insight without Interference
System insight without InterferenceSystem insight without Interference
System insight without Interference
 
Using Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systemsUsing Smalltalk for controlling robotics systems
Using Smalltalk for controlling robotics systems
 
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & MobileIVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
IVS CTO Night And Day 2018 Winter - [re:Cap] Serverless & Mobile
 
Server Side Swift
Server Side SwiftServer Side Swift
Server Side Swift
 
How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.How bol.com makes sense of its logs, using the Elastic technology stack.
How bol.com makes sense of its logs, using the Elastic technology stack.
 
Deep Learning for Unified Personalized Search and Recommendations - Jake Mann...
Deep Learning for Unified Personalized Search and Recommendations - Jake Mann...Deep Learning for Unified Personalized Search and Recommendations - Jake Mann...
Deep Learning for Unified Personalized Search and Recommendations - Jake Mann...
 
Deep Learning for Search: Personalization and Deep Tokenization
Deep Learning for Search: Personalization and Deep TokenizationDeep Learning for Search: Personalization and Deep Tokenization
Deep Learning for Search: Personalization and Deep Tokenization
 
Advanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCONAdvanced SOHO Router Exploitation XCON
Advanced SOHO Router Exploitation XCON
 
Anish PPT-GIT.pptx
Anish PPT-GIT.pptxAnish PPT-GIT.pptx
Anish PPT-GIT.pptx
 
Format of first slide for main PPT-GIT.pptx
Format of first slide for main PPT-GIT.pptxFormat of first slide for main PPT-GIT.pptx
Format of first slide for main PPT-GIT.pptx
 
PPT-GIT.pptx
PPT-GIT.pptxPPT-GIT.pptx
PPT-GIT.pptx
 
Building a company-wide data pipeline on Apache Kafka - engineering for 150 b...
Building a company-wide data pipeline on Apache Kafka - engineering for 150 b...Building a company-wide data pipeline on Apache Kafka - engineering for 150 b...
Building a company-wide data pipeline on Apache Kafka - engineering for 150 b...
 
Developing apps using Perl
Developing apps using PerlDeveloping apps using Perl
Developing apps using Perl
 
Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"Travis Oliphant "Python for Speed, Scale, and Science"
Travis Oliphant "Python for Speed, Scale, and Science"
 
Open Source Swift Under the Hood
Open Source Swift Under the HoodOpen Source Swift Under the Hood
Open Source Swift Under the Hood
 
Monitoring and Debugging your Live Applications
Monitoring and Debugging your Live ApplicationsMonitoring and Debugging your Live Applications
Monitoring and Debugging your Live Applications
 
Flask With Server-Sent Event
Flask With Server-Sent EventFlask With Server-Sent Event
Flask With Server-Sent Event
 
Distributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromqDistributed app development with nodejs and zeromq
Distributed app development with nodejs and zeromq
 
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon YangPractical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
Practical IoT Exploitation (DEFCON23 IoTVillage) - Lyon Yang
 
OSDC 2016 - Ingesting Logs with Style by Pere Urbon-Bayes
OSDC 2016 - Ingesting Logs with Style by Pere Urbon-BayesOSDC 2016 - Ingesting Logs with Style by Pere Urbon-Bayes
OSDC 2016 - Ingesting Logs with Style by Pere Urbon-Bayes
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 

Último (20)

Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
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
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 

ErLounge SF/Bay: 2010.01.12 Christian Westbrook / CoTweet

Notas del editor

  1. Christian Westbrook2010.1.12 ErLounge SF/Bay cw@props.org meetup.com/erlounge
  2. Thanks for coming out
  3. Nothing technically wrong with this: did, in fact, get working w/ plists - parallel processing, but not concurrent services - stateless! robot has no idea what&amp;#x2019;s going on, ever. ... one of the misconceptions some beginners have about erlang -&gt;
  4. all state: robot config, list of channels to service, perceived state of: { twitter api, db, cache } Benefits: smooth workload rather than bursts tapering off each iteration of service loop can mix in business logic to govern usage But: worst case, worker procs can still block waiting for database -- precluding cache insert
  5. Benefits:
  6. :
  7. don&amp;#x2019;t hit anything :3