•      
  • Garbage Burrito!An online internet web blog by Ben Kittrell
  • Blog
  • Tweets
  • Contact
  • Photos
  • Favorite Burrito
  • Burrito Shop
  • Cart
  • Login
  •      
 View Cart Login        

Garbage Burrito!

An online internet web blog by Ben Kittrell

  • Blog
  • Tweets
  • Contact
  • Photos
  • Favorite Burrito
  • Burrito Shop

 About Ben

Co-Founder of Doodlekit. Coder, Home Renovator, Enjoyer of Refreshing Beverages.

Sometimes I blog here, sometimes on Doodlekit, sometimes I tweet and now I podcast.

Most recently I've been doing software development strategy consulting for Kansas City businesses.  

 Doodlekit

Doodlekit is the easiest way for small businesses to create their own website.  Used by millions in over 180 countries.

Follow us for updates.

Doodlekit on Twitter
AngelList
LinkedIn
Facebook

160x600.gif

free website builder

 

 Blog Entries

  • Great Review of Doodlekit by Comparakeet
  • New Podcast Episode - Danny O'Neill - The Roasterie - Spare Room Radio
  • What I Wish Someone Told Me Before I Started Buying Podcast Equipment
  • Announcing Spare Room Radio - New Podcast
  • Google Fiber Experiment: Cloud Video Transcoding
more  

 Links


  • website reviewer
  • live on - sharing memories
  • kids website builder
  • resume website
  • martial arts website builder
  • affiliate website builder
  • teacher website

 Login

 Forgot Password?

 Forum Posts

  • rajablogid: RE: Stupid Simple, Yet Effective
  • julie mack: RE: JavaScripting with PDF's?
  • Megan Cunningham: RE: Java Generics
  • Deepika Sharma: RE: Grilled Cheese
  • German Byrd: RE: Grilled Cheese
more  

 Custom Login

 Forgot Password?
 Register

 Back to Blog

Sequence Diagrams for Asynchronous Flows in Node.js

Ben Kittrell
 06/13/2012 05:09PM

 

If you're getting started with Node.js, like I am, chances are you're having a hard time grokking asynchronous workflows.  I'm typically a "just dive right in and kick it till it works" kind of guy, but I've been trying to discipline myself a little more and do some planning.  After trying some different techniques I found sequence diagrams to be very helpful.  I guess I did learn something from all of those years of corporate Java development.

Sequence Wha?

For those unfamiliar, in a sequence diagram, the vertical lines represent components in your application or architecture and the horizontal lines represent messages between them.  The white vertical rectangles represent the life that particular component.

Examples

I'm working on a Node.js media server.  Here's a diagram of a potential slave replication flow.

VaultSequenceUpload.jpg

 

Right away you can see that there is nothing asynchronous about this.  The browser has to wait for a lot of stuff to finish before the connection is released.  In reality, the connection could be released as soon as the file is saved. 

Here's an improved flow, with the addition of video transcoding.

VaultSequence.jpg

 

The file is uploaded, and an asynchronous video transcoding job is started.  Right away we replicate the original file to the slaves.  At this point, everything is in the hands of the transcoding job.  When it's complete, we download the completed files, set the metadata such as the duration, replicate to the slaves and set the status as finished.

You can easily see that the browser session is very short, which is what we want in an asynchronous flow.  As soon as the uploaded file is saved to disk, it returns a 200 and then starts the a video transcoding job.   Also, we can start copying the original file to the slaves before the transcoding is finished.

It's also clear that some pieces still need to be synchronous.  We can't replicate the the slaves until we have the files and the metadata, and we can't set the status to finished until the files are replicated.

However, it also shows a weakness in this flow.  The only thing that can complete the flow is a message back from the video transcoder.  If that message is never sent, we have an orphaned file.  This suggests that we may need something to check for failed jobs and retry.

I used OmniGraffle for these, but you can also just draw them out on paper.

IMG_0307.jpg

Tags: nodejs, uml, javascript, programming

 Comments

 Patrick Mueller My Website  06/13/2012 09:16PM 

http://www.websequencediagrams.com/ ???

 Langdon  06/14/2012 05:45AM 

this doesn't seem like it would scale if the master is receiving files from the browser. the master would be a bottleneck if you plan on having multiple users upload files.

slaves should be receiving the files and either queueing jobs for the master to handle and replicate, or they should be doing the work themselves and be aware of other slaves in the array that they need to replicate to.

 Ben Kittrell  06/14/2012 04:17PM 

Patrick, Nice Link!

Langdon, That's a good point, and something I'll consider. One part of the design that isn't in this article is the load balancing. Let's say I need to get the URL for an <img tag. The app that generates the URL will have a "Registry" from the media server that tells it the host names of the master and all of the slaves. If the app knows that the file is "Finished" (replicated) then it will choose a random URL from the registry. Otherwise it uses the Master URL. Too your point that would add even more stress to the master.

I guess I could have the app keep track of where it uploaded the file, instead of just assuming it was the master. In that case there would be no need for a master, just a cluster of nodes. Something for me to chew on.

 rheaghen  07/02/2012 10:55PM 

JavaScript is very good at handling variable args :)

[code]
function foo(){
alert(arguments.length)
}

foo(1);
foo(1,2);
[/code]

 Juli  02/19/2015 01:44PM 

I have no words to appreciate this post ..... I'm really impressed with this post .... the person who created this post was a big thank you man .. for sharing with us.
http://www.wedding-bliss.org

 Nancy  03/03/2015 06:49AM 

Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you.
www.autoskola-hyvnar.org

 Nancy  03/05/2015 10:02AM 

Hey what a brilliant post I have come across and believe me I have been searching out for this similar kind of post for past a week and hardly came across this. Thank you very much and will look for more postings from you.
http://www.computeroutlets.org

 Amy  03/06/2015 10:40AM 

I really enjoy simply reading all of your weblogs. Simply wanted to inform you that you have people like me who appreciate your work. Definitely a great post
http://www.winetourtemecula.com

 David  03/11/2015 09:55AM 

I've seen your awareness about this theme whenever you post it and it really gives an informational message to us readers. I am hoping that you'll continue writing this kind of blog. Thanks for sharing this information.
http://www.residenttechnologies.com

 Amy  04/01/2015 12:44PM 

Must say that overall I am really impressed with this blog. It is easy to see that you are passionate about your writing. If only I had your writing ability I look forward to more updates and will be returning.
http://www.anyonecanbe.co.uk

 Andreas  04/21/2015 05:43PM 

Hello Ben,

Thanks for the post.

i would also like to ask you, is there any plugin, program etc to automatically create a flow chart or a state diagram directly after importing my source code?

 Abbi  05/19/2015 09:34AM 

This is such a great resource that you providing and you give it away for free.
http://www.fedes.net

  05/27/2016 01:53PM 

I am very happy about the sequence diagram for having this one. The blog helps every user to get many www.thebestessayshelp.net web articles. Every diagram is important to all of us and the details really useful to get more knowledge.

 clash  06/01/2016 10:37PM 

Cheats in clash royale are not of any worth for me, even though we can create free gems using the clash royale hack from this webpage http://freeclashroyalehacker.net it obviously ruin the gameplay. Getting free gems for clash royale can make you powerful, but use clash royale cheats on your own risk.

  06/19/2016 01:05PM 

Its nice post ! Thanks for sharing such wonderful article. Keep sharing. Waiting for more.I'm going to subscribe so that i can come to know every updates! Get digital marketing course pakistan from http://www.pnytrainings.com/social-media-marketing-training-lahore/

  07/07/2016 12:57PM 

I have read the topic to learn sequence diagrams http://legitimate-writing-services.blogspot.com/2016/06/ukessays-com-review.html websites. The details you can find from this blog with great features. Everything we are needed to get many opportunities and asyn articles.

  07/12/2016 03:32PM 

This was one of the most well documented blog entries I have read in a long time. It was a pleasure to fill all the gaps I had about this topic. Well written an concise. Get gym flooring easy to wipe from http://www.gymflooringco.co.uk/gym-flooring.html

 Phillip Niosi  09/03/2016 09:33PM 

As most fans know, the upcoming season 6 of Teen wolf http://teenwolfonline.us of the show will serve as its last on TV, which came as a disappointment to viewers of the drama.

 alaa baali My Website  10/08/2016 09:11PM 

Great article by Ben Kittrell , thanks for sharing great knowledge.
I can't tell you that i gain lot of knowledge from this article.
I also write article on domain name registration service <a href:"http://cashhost.net"> domain name registration

service </a> for additional features of domain name registration service.
Thank you so much again

 Pet-Fashion My Website  10/15/2016 07:41PM 

this is a great article and give more information for visitors
also read my article hope this will be help you in pets industry https://www.pet-fashion.co.uk

 Indian face massage courses My Website  10/19/2016 10:25PM 

very good indian face massage you can use easily and buy from our website http://marys-courses.thinkific.com/courses/indian-head-massage
you can easily buy from this website

 virgana  10/25/2016 09:04PM 

<a href="serialgamingonline.net">Serial Gaming Online</a> will relieve all your stress and take your game to a high new level!

  10/25/2016 09:05PM 

http://serialgamingonline.net will relieve all your stress and take your game to a high new level!

 Alex John My Website  10/26/2016 01:19PM 

if you want rent a car in moroco, then simply visit this website http://www.cosmos-car.com/
and get good and cheap plans

 FELT BALL RUGS My Website  10/29/2016 06:36PM 

What an informative article, Felt Ball Rugs have become very popular item nowadays in the area of

home, office and baby nurseries decoration. I also write article on https://www.mimosacrafts.com.au/felt-ball-crafts-australia/felt-ball-rugs. Please Read this
Thanks
Regards
Alex John

 Waqas Cheema  11/18/2016 01:46PM 

Wi-Fi router technology has made very quick changes from the past few decades. With increased use of

Smartphones, gaming consoles and other network-based gadgets, the need for a good router has also elevated

drastically. For complete article please visit http://bestcomputersforgaming.com/best-wireless-routers/

 Beena My Website  11/20/2016 11:00AM 

Great article| this article is very informative to its reader.

 Polkaline My Website  11/28/2016 02:05PM 

These are beautiful Mexican style heavy duty hooded ponchos. Made by our skilled artisan from 100% cotton (also known as Shyama or Gheri Cotton). These Baja Style Nepalese Hooded Poncho are available in two types; Brushed and Unbrushed. The brushed poncho has its outer part hand brushed for fuzzy looking and warm feelings though both types are very warm. visit for complete details
https://www.mimosacrafts.com.au/clothing/mens-clothing/mens-poncho

 Bob My Website  12/10/2016 07:55PM 

Good news for me!
Thanks a lot...
http://www.purevolume.com/bingo49634

 ES File Explorer Apk My Website  02/19/2017 08:35PM 

ES File Explorer Apk

 ES File Explorer Pro App My Website  02/20/2017 12:09AM 

https://www.esfileexplorerproapk.com/

 Goat Simulator Apk My Website  02/20/2017 12:09AM 

https://www.goatsimulatorapk.com/

 good My Website  03/30/2017 05:05PM 

nice post. also check free movie streaming sites here: https://www.goodtechtricks.com/top-best-free-movie-streaming-sites-2016/

 Copa Del Rey 2017 Live Streaming My Website  04/09/2017 08:44PM 

http://www.barcelonavsalavescdrfinal.com/

 iZombie Season 3 Release Date My Website  04/19/2017 05:24PM 

iZombie Season 3 will portray Liv gulping down the brain of a dominatrix. Therefore, we can expect the upcoming installment to be more engaging than the previous ones.

 http://worldcosplay.net/member/608324  04/20/2017 06:36AM 

I would like to appreciate your properly written content it's useful and your writing concept helped me to the idea without the difficulty. Thanks http://worldcosplay.net/member/608324

 http://8tracks.com/bliherbalsehat  04/20/2017 06:36AM 

I found useful information on this topic as I will be taking care of a company project. Thanks a lot posting relative information and its currently becoming easier to finish this project http://8tracks.com/bliherbalsehat

 http://www.bookcrossing.com/mybookshelf/bliherbal/  04/20/2017 06:37AM 

Now i'm currently focusing on an assignment and I have been exploring your page for a few hours. I'm appreciate your the idea proved valuable for me. http://www.bookcrossing.com/mybookshelf/bliherbal/

 Nox App Player Apk Download My Website  04/24/2017 10:38PM 

https://noxappplayers.org/

 etnryhtj  04/26/2017 08:07PM 

https://www.bestlaptopsunder500d.com/

 adward  05/10/2017 07:38AM 

Interesting post! I really impressed to read the great information that you have shared with us. Keep doing the great work up. http://callatlantaplumber.com/ is the best home services.

 walmart credit card login My Website  05/13/2017 04:55PM 

http://walmart-creditcardlogin.org/

 henry  05/26/2017 04:30PM 

Amazing work! I really impressed to see the information that you have shared with us. I want to say thanks to you for the sharing of this great post. http://www.netwising.com/

 henry  05/26/2017 04:31PM 

Amazing work! I really impressed to see the information that you have shared with us. I want to say thanks to you for the sharing of this great post. http://www.netwising.com/

 Sue  06/09/2017 03:33PM 

http://blog.dnevnik.hr/girlchat
http://clickandchat.eklablog.com/
http://jemmawilkins.doodlekit.com/

 credit card status My Website  06/13/2017 12:24PM 

Tracking Axis bank credit card status details is easy now-a-days

 Maggie G. Enoch  06/21/2017 10:01PM 

my website. please checkout.
http://rootexplorerapk.net/

 steve  07/07/2017 04:11PM 

For its new Hulu Live service, MoffettNathanson uses a range of calculating advertising at $5.89 to $9.82 per subscriber per month. It also assumes an average consumer monthly price for Hulu Live at $40 -- the current price of the package.

For its non-linear, on-demand programming service, Hulu is estimated to have generated $8 to $9 per subscriber per month, factoring in lower advertising loads and healthy CPM priced ad units.

By way of comparison, estimates from Hulu’s existing businesses indicate the company pulls in just over $900 million annually in advertising.

Last year, Alexia Quadrani, media analyst of J.P. Morgan, estimated that Hulu revenues -- from its legacy ad-supported on-demand service, Hulu, and its non-advertising service Hulu Plus -- would total $2.4 billion in 2017. (That counts 61% from subscribers revenues/39% from advertising).

https://helpguide.co/hulu-plus-login-sign-in-www-hulu-com/

 Dylan  07/11/2017 11:41AM 

I think this might be helpful: 192.168.0.1 https://19216801help.com/

 alan My Website  07/14/2017 01:48PM 

https://www.downloadtubemateforpc.com/
https://www.downloadtubemateforpc.com/tubemate-apk-for-android-free-download/
https://www.downloadtubemateforpc.com/tubemate-for-mac-pc-free-download/

 Previous 1 2 3 Next 

 Search

Follow On...

  • Facebook
  • Twitter
  • LinkedIn
  • Google+
  • Pinterest
  • RSS Feeds
  • Blog Posts,
  • Gallery Images,
  • Forum Topics

Copyright © 2006 Garbage Burrito. All Rights Reserved.
hosted by doodlekit™- free website builder

 

 powered by Doodlekit™ Free Website Builder