SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
When to use Node.js?
                       Lessons learned
                         Coen Stevens - Amsterdam Node Meetup 2012




                  @beatlevic           BeatleTech.com


Saturday, March 31, 12
W2010

Saturday, March 31, 12
Why not Node.js
            • We never heard of Node.js at the time (2009)
                    and were experienced in Ruby
            • Lots of server-side computations / statistics /
                    map-reduce (blocking the node event-loop)
            • Typical dashboard (view on a database)
            • Not that many concurrent users
            • No need for open connections
                                     Yes, I would use Ruby again
Saturday, March 31, 12
Pivot: Penny auctions


                     • Swoopo and Bigdeal (real goods)
                     • Newcope a platform for pay-per-bid
                         auction games for virtual goods




Saturday, March 31, 12
Flash game platform




                         http://newcope-heyzap.heroku.com/home
Saturday, March 31, 12
• The Broth: BarnBuddy
                     • Facebook app
                     • Similar to Farmville
                     • Over 1 million active users per month

Saturday, March 31, 12
Challenge

                     • Build iframe / facebook app solution
                     • Have the auctions as realtime as possible
                     • Long polling (later websockets) vs pulling
                     • Lots of users with open connections
                     • Scalable

Saturday, March 31, 12
Languages considered

                 • Ruby (Eventmachine, no Goliath yet)
                 • JRuby
                 • Scala (Twitter had just moved from ruby)
                 • Erlang
                 • Javascript Node.js

Saturday, March 31, 12
Saturday, March 31, 12
Node.js experiences
           •       Functional programming

           •       Javascript for both client and server

           •       Very good performance (30k users the first day)

           •       Node v0.1.25 and no packet manager (npm)

           •       MySQL with DBSlayer (later Mongodb)

           •       Nginx to serve static files

           •       Easy to setup/deploy on EC2 (upstart deamon)

           •       Everything async (annoying to test)

           •       Fun!
                                          Yes, I would use Node.js again
Saturday, March 31, 12
Auction.prototype.startTimer = function() {
         var self = this;   
         if (this.timer) clearTimeout(this.timer);
         this.emit("start");  
         this.timer = setTimeout(function() {
           self.emit("end");
         }, self.timeLeft() * 1000);
       }

       Auction.prototype.bid = function(user) {
           var self = this;
           return function (callback, errback) {
            if (user.bid_count > 0 && self.status() === "running") {
               user.bid_count -= 1;
               dbUser.updateUser(user.id, {'bid_count': user.bid_count})(function(result){
                 if (self.timeLeft() < self.bidTimeDelta) {
                   self.setTime(me.bidTimeDelta);
                 };
                 self.price += self.bidPriceDelta;
                 var bid = { user: user, ts: new Date() }
                 self.bids.push(bid);
                 self.bidCount++;
                 callback(self);
               }, function(error) {
                 user.bid_count += 1;
                 errback("Could not update new bid count");
               })
            } else {
               errback("Bid could not be placed");
            }
         };
       }


Saturday, March 31, 12
// continuation style
       var bid = function(user) {
           return function (callback, errback) {
             if (!user) return errback("No user")
             callback(user)
           }
       }

       bid(user)(function(result){
          console.log(result)
       }, function(error) {
          console.log(error)
       })




Saturday, March 31, 12
// promise style
       var bid = function(user) {
         var promise = new Promise()
         if (!user) {
           promise.emitError("No user")
         } else {
           promise.emitSuccess(user)
         }
         return promise
       }

       var promise = bid(user)
       promise.addErrback(function(error){
          console.log(error)
       })
       promise.addCallback(function(result) {
          console.log(result)
       })




Saturday, March 31, 12
•   // callback style
       var bid = function(user, callback) {
         if (!user) return callback("No user")
         callback(null, user);
       }

       bid(user, function(err, result){
          if (err) console.log(err)
          console.log(result)
       })




Saturday, March 31, 12
• Bottlenose is the smartest social media
                         dashboard.
              • Helping you manage the information overload
                         on streams like twitter and Facebook
              • Bottlenose analyzes and filters messages using
                         NLP and clustering techniques
              • Beta launched December 2011
                                      http://bottlenose.com
Saturday, March 31, 12
Saturday, March 31, 12
Why Node.js?
                     • It began (2009) with NLP in javascript, run
                         it both on the client and the server
                     • Fat client and lean server
                     • Realtime stream updates
                     • Lots of users (with open connections)
                     • Alternatives?
                                        Yes, I would use Node.js again
Saturday, March 31, 12
Summary:
                          When to use Node?
              • When you are building more of an app than a
                         website and require lots of open connections to
                         the server
              • When you want your users to get data in
                         realtime (chat, streams)
              • When you have to serve lots of requests that do
                         not take too many cpu cycles (blocking the loop)
              • When you like to work with Javascript all the way
Saturday, March 31, 12
Thanks!




                  @beatlevic
Saturday, March 31, 12

Contenu connexe

En vedette

Voting presentation
Voting presentationVoting presentation
Voting presentationhannahfenney
 
Evaluation for the music magazine
Evaluation for the music magazineEvaluation for the music magazine
Evaluation for the music magazineLiam Wylie
 
Digital Audio/Podcast Assignment
Digital Audio/Podcast AssignmentDigital Audio/Podcast Assignment
Digital Audio/Podcast AssignmentJordan Kelly
 
Simplify and run your development environments with Vagrant on OpenStack
Simplify and run your development environments with Vagrant on OpenStackSimplify and run your development environments with Vagrant on OpenStack
Simplify and run your development environments with Vagrant on OpenStackB1 Systems GmbH
 
The Poker Entrepreneurship: Speaking @ JFDI.Asia
The Poker Entrepreneurship: Speaking @ JFDI.AsiaThe Poker Entrepreneurship: Speaking @ JFDI.Asia
The Poker Entrepreneurship: Speaking @ JFDI.Asiasaumilnanavati
 
Steps presentation
Steps presentationSteps presentation
Steps presentationLiam Wylie
 
Internationaal privaatrecht en fundamentele rechten. Ipr als instrument ter b...
Internationaal privaatrecht en fundamentele rechten. Ipr als instrument ter b...Internationaal privaatrecht en fundamentele rechten. Ipr als instrument ter b...
Internationaal privaatrecht en fundamentele rechten. Ipr als instrument ter b...Veerle Van Den Eeckhout
 
P m01 inside_selling
P m01 inside_sellingP m01 inside_selling
P m01 inside_sellingFitira
 
班级新变化
班级新变化班级新变化
班级新变化jody531
 
Marketing Management
Marketing ManagementMarketing Management
Marketing Managementrsinghkaurav
 
Facebook-Zynga
Facebook-ZyngaFacebook-Zynga
Facebook-Zyngagndolf
 
Actualiteiten IPR: Nieuw Boek 10 BW; What's new in het ipr?
Actualiteiten IPR: Nieuw Boek 10 BW; What's new in het ipr?Actualiteiten IPR: Nieuw Boek 10 BW; What's new in het ipr?
Actualiteiten IPR: Nieuw Boek 10 BW; What's new in het ipr?Veerle Van Den Eeckhout
 
Images for the Clouds with KIWI & OBS
Images for the Clouds with KIWI & OBSImages for the Clouds with KIWI & OBS
Images for the Clouds with KIWI & OBSB1 Systems GmbH
 
Social game의 가까운 미래
Social game의 가까운 미래Social game의 가까운 미래
Social game의 가까운 미래gndolf
 
Digital Audio/Podcast Assignment
Digital Audio/Podcast AssignmentDigital Audio/Podcast Assignment
Digital Audio/Podcast AssignmentJordan Kelly
 
Anatomyofa twitterrumor
Anatomyofa twitterrumorAnatomyofa twitterrumor
Anatomyofa twitterrumorGnip
 
Deploying oracle rac 10g with asm on rhel and sles with svc
Deploying oracle rac 10g with asm on rhel and sles with svcDeploying oracle rac 10g with asm on rhel and sles with svc
Deploying oracle rac 10g with asm on rhel and sles with svcwikiwei
 

En vedette (20)

Voting presentation
Voting presentationVoting presentation
Voting presentation
 
Evaluation for the music magazine
Evaluation for the music magazineEvaluation for the music magazine
Evaluation for the music magazine
 
Gulteal region
Gulteal regionGulteal region
Gulteal region
 
Digital Audio/Podcast Assignment
Digital Audio/Podcast AssignmentDigital Audio/Podcast Assignment
Digital Audio/Podcast Assignment
 
Simplify and run your development environments with Vagrant on OpenStack
Simplify and run your development environments with Vagrant on OpenStackSimplify and run your development environments with Vagrant on OpenStack
Simplify and run your development environments with Vagrant on OpenStack
 
The Poker Entrepreneurship: Speaking @ JFDI.Asia
The Poker Entrepreneurship: Speaking @ JFDI.AsiaThe Poker Entrepreneurship: Speaking @ JFDI.Asia
The Poker Entrepreneurship: Speaking @ JFDI.Asia
 
Reference_Letter
Reference_LetterReference_Letter
Reference_Letter
 
Steps presentation
Steps presentationSteps presentation
Steps presentation
 
Internationaal privaatrecht en fundamentele rechten. Ipr als instrument ter b...
Internationaal privaatrecht en fundamentele rechten. Ipr als instrument ter b...Internationaal privaatrecht en fundamentele rechten. Ipr als instrument ter b...
Internationaal privaatrecht en fundamentele rechten. Ipr als instrument ter b...
 
P m01 inside_selling
P m01 inside_sellingP m01 inside_selling
P m01 inside_selling
 
班级新变化
班级新变化班级新变化
班级新变化
 
Marketing Management
Marketing ManagementMarketing Management
Marketing Management
 
Facebook-Zynga
Facebook-ZyngaFacebook-Zynga
Facebook-Zynga
 
Actualiteiten IPR: Nieuw Boek 10 BW; What's new in het ipr?
Actualiteiten IPR: Nieuw Boek 10 BW; What's new in het ipr?Actualiteiten IPR: Nieuw Boek 10 BW; What's new in het ipr?
Actualiteiten IPR: Nieuw Boek 10 BW; What's new in het ipr?
 
Images for the Clouds with KIWI & OBS
Images for the Clouds with KIWI & OBSImages for the Clouds with KIWI & OBS
Images for the Clouds with KIWI & OBS
 
Social game의 가까운 미래
Social game의 가까운 미래Social game의 가까운 미래
Social game의 가까운 미래
 
Digital Audio/Podcast Assignment
Digital Audio/Podcast AssignmentDigital Audio/Podcast Assignment
Digital Audio/Podcast Assignment
 
House for sale
House for saleHouse for sale
House for sale
 
Anatomyofa twitterrumor
Anatomyofa twitterrumorAnatomyofa twitterrumor
Anatomyofa twitterrumor
 
Deploying oracle rac 10g with asm on rhel and sles with svc
Deploying oracle rac 10g with asm on rhel and sles with svcDeploying oracle rac 10g with asm on rhel and sles with svc
Deploying oracle rac 10g with asm on rhel and sles with svc
 

Similaire à When to use Node? Lessons learned

node.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicornnode.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicornbcantrill
 
node.js in action
node.js in actionnode.js in action
node.js in actionKaran Misra
 
Everything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptEverything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptBill Buchan
 
Softshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with CouchbaseSoftshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with CouchbaseTugdual Grall
 
How to Make Norikra Perfect
How to Make Norikra PerfectHow to Make Norikra Perfect
How to Make Norikra PerfectSATOSHI TAGOMORI
 
A Morning with MongoDB Barcelona: Use Cases and Roadmap
A Morning with MongoDB Barcelona: Use Cases and RoadmapA Morning with MongoDB Barcelona: Use Cases and Roadmap
A Morning with MongoDB Barcelona: Use Cases and RoadmapMongoDB
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartMukesh Singh
 
Concurrency (Fisher Syer S2GX 2010)
Concurrency (Fisher Syer S2GX 2010)Concurrency (Fisher Syer S2GX 2010)
Concurrency (Fisher Syer S2GX 2010)Dave Syer
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profilingOpen Academy
 
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Máté Nádasdi
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive uiPaul van Zyl
 
FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023Matthew Groves
 
Design of Experiments on Federator Polystore Architecture
Design of Experiments on Federator Polystore ArchitectureDesign of Experiments on Federator Polystore Architecture
Design of Experiments on Federator Polystore ArchitectureLuiz Henrique Zambom Santana
 
Gopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowGopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowMateuszSzczyrzyca
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScriptYnon Perek
 

Similaire à When to use Node? Lessons learned (20)

node.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicornnode.js in production: Reflections on three years of riding the unicorn
node.js in production: Reflections on three years of riding the unicorn
 
node.js in action
node.js in actionnode.js in action
node.js in action
 
Everything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus scriptEverything you ever wanted to know about lotus script
Everything you ever wanted to know about lotus script
 
Node.js
Node.jsNode.js
Node.js
 
Softshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with CouchbaseSoftshake 2013: Introduction to NoSQL with Couchbase
Softshake 2013: Introduction to NoSQL with Couchbase
 
How to Make Norikra Perfect
How to Make Norikra PerfectHow to Make Norikra Perfect
How to Make Norikra Perfect
 
Nexmark with beam
Nexmark with beamNexmark with beam
Nexmark with beam
 
A Morning with MongoDB Barcelona: Use Cases and Roadmap
A Morning with MongoDB Barcelona: Use Cases and RoadmapA Morning with MongoDB Barcelona: Use Cases and Roadmap
A Morning with MongoDB Barcelona: Use Cases and Roadmap
 
Ledingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @LendingkartLedingkart Meetup #2: Scaling Search @Lendingkart
Ledingkart Meetup #2: Scaling Search @Lendingkart
 
Concurrency (Fisher Syer S2GX 2010)
Concurrency (Fisher Syer S2GX 2010)Concurrency (Fisher Syer S2GX 2010)
Concurrency (Fisher Syer S2GX 2010)
 
Dev tools rendering & memory profiling
Dev tools rendering & memory profilingDev tools rendering & memory profiling
Dev tools rendering & memory profiling
 
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
Google Chrome DevTools: Rendering & Memory profiling on Open Academy 2013
 
All about that reactive ui
All about that reactive uiAll about that reactive ui
All about that reactive ui
 
FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023FluentMigrator - Dayton .NET - July 2023
FluentMigrator - Dayton .NET - July 2023
 
Design of Experiments on Federator Polystore Architecture
Design of Experiments on Federator Polystore ArchitectureDesign of Experiments on Federator Polystore Architecture
Design of Experiments on Federator Polystore Architecture
 
Cloud accounting software uk
Cloud accounting software ukCloud accounting software uk
Cloud accounting software uk
 
Gopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracowGopher in performance_tales_ms_go_cracow
Gopher in performance_tales_ms_go_cracow
 
Js memory
Js memoryJs memory
Js memory
 
Scalable JavaScript
Scalable JavaScriptScalable JavaScript
Scalable JavaScript
 
Big Data Tutorial V4
Big Data Tutorial V4Big Data Tutorial V4
Big Data Tutorial V4
 

Dernier

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
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
 
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
 
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
 
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 future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...Neo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
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
 

Dernier (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
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
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
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
 
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
 
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
 
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 future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
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)
 

When to use Node? Lessons learned

  • 1. When to use Node.js? Lessons learned Coen Stevens - Amsterdam Node Meetup 2012 @beatlevic BeatleTech.com Saturday, March 31, 12
  • 3. Why not Node.js • We never heard of Node.js at the time (2009) and were experienced in Ruby • Lots of server-side computations / statistics / map-reduce (blocking the node event-loop) • Typical dashboard (view on a database) • Not that many concurrent users • No need for open connections Yes, I would use Ruby again Saturday, March 31, 12
  • 4. Pivot: Penny auctions • Swoopo and Bigdeal (real goods) • Newcope a platform for pay-per-bid auction games for virtual goods Saturday, March 31, 12
  • 5. Flash game platform http://newcope-heyzap.heroku.com/home Saturday, March 31, 12
  • 6. • The Broth: BarnBuddy • Facebook app • Similar to Farmville • Over 1 million active users per month Saturday, March 31, 12
  • 7. Challenge • Build iframe / facebook app solution • Have the auctions as realtime as possible • Long polling (later websockets) vs pulling • Lots of users with open connections • Scalable Saturday, March 31, 12
  • 8. Languages considered • Ruby (Eventmachine, no Goliath yet) • JRuby • Scala (Twitter had just moved from ruby) • Erlang • Javascript Node.js Saturday, March 31, 12
  • 10. Node.js experiences • Functional programming • Javascript for both client and server • Very good performance (30k users the first day) • Node v0.1.25 and no packet manager (npm) • MySQL with DBSlayer (later Mongodb) • Nginx to serve static files • Easy to setup/deploy on EC2 (upstart deamon) • Everything async (annoying to test) • Fun! Yes, I would use Node.js again Saturday, March 31, 12
  • 11. Auction.prototype.startTimer = function() { var self = this;    if (this.timer) clearTimeout(this.timer);   this.emit("start");     this.timer = setTimeout(function() {     self.emit("end");   }, self.timeLeft() * 1000); } Auction.prototype.bid = function(user) {     var self = this;     return function (callback, errback) {      if (user.bid_count > 0 && self.status() === "running") {         user.bid_count -= 1;         dbUser.updateUser(user.id, {'bid_count': user.bid_count})(function(result){           if (self.timeLeft() < self.bidTimeDelta) {             self.setTime(me.bidTimeDelta);           };           self.price += self.bidPriceDelta;           var bid = { user: user, ts: new Date() }           self.bids.push(bid);           self.bidCount++;           callback(self);         }, function(error) {           user.bid_count += 1;           errback("Could not update new bid count");         })      } else {         errback("Bid could not be placed");      }   }; } Saturday, March 31, 12
  • 12. // continuation style var bid = function(user) {     return function (callback, errback) { if (!user) return errback("No user") callback(user) } } bid(user)(function(result){ console.log(result) }, function(error) { console.log(error) }) Saturday, March 31, 12
  • 13. // promise style var bid = function(user) { var promise = new Promise() if (!user) { promise.emitError("No user") } else { promise.emitSuccess(user) }   return promise } var promise = bid(user) promise.addErrback(function(error){ console.log(error) }) promise.addCallback(function(result) { console.log(result) }) Saturday, March 31, 12
  • 14. // callback style var bid = function(user, callback) { if (!user) return callback("No user") callback(null, user); } bid(user, function(err, result){ if (err) console.log(err) console.log(result) }) Saturday, March 31, 12
  • 15. • Bottlenose is the smartest social media dashboard. • Helping you manage the information overload on streams like twitter and Facebook • Bottlenose analyzes and filters messages using NLP and clustering techniques • Beta launched December 2011 http://bottlenose.com Saturday, March 31, 12
  • 17. Why Node.js? • It began (2009) with NLP in javascript, run it both on the client and the server • Fat client and lean server • Realtime stream updates • Lots of users (with open connections) • Alternatives? Yes, I would use Node.js again Saturday, March 31, 12
  • 18. Summary: When to use Node? • When you are building more of an app than a website and require lots of open connections to the server • When you want your users to get data in realtime (chat, streams) • When you have to serve lots of requests that do not take too many cpu cycles (blocking the loop) • When you like to work with Javascript all the way Saturday, March 31, 12
  • 19. Thanks! @beatlevic Saturday, March 31, 12