0

I am brand new to Node.js, and trying to figure out a few things:

1.) When i run the server on node.js(connect to localhost database and do an insert function to the db), not sure why the console.log won't appear for quite a while. Sometimes up to half a min. Just wondering if Terminal has delays?

2.) I am also looking to see how to get siege working, I am on a mac on terminal. used npm install node-siege. But I have no idea how am I supposed to run it.

I saw a tutorial that, I am supposed to run the server first $ node file.js then do

$ siege -c10 -t1M http://localhost:3000 but it doesn't do anything. Any hint on what am I supposed to do to run siege?

I did $ siege -c10 -t1M http://localhost:3000 then siege -c10 -t1M http://localhost:3000 none of it gives shows anything in terminal.

Community
  • 1
  • 1
John
  • 983
  • 1
  • 13
  • 31

1 Answers1

0

1) Synchronous code

Synchronous code doesn't let other stuff run until it's done. It stops the thread from doing literally anything(including serving other requests) until it's done.

They're evil. Don't use synchronous variants of code(i.e. fs.readFileSync unless on startup, where performance is irrelevant and it's acceptable. Also, by doing stuff synchronously you forget that one of the reasons Node is so fast is that it does stuff asynchronously.

Most likely you're sending a request to a database that doesn't want to respond or doing a HTTP request on a slow network - or maybe even something else that needs a lot of IO, and the console.log() gets queued until after it's done.

Or, it's just a callback flaw, so, you might want to post some code, because I can't tell you for sure until I see your code.

2) node-siege

You forgot the -g or --global tag. Try this: sudo npm install node-siege -g.

Gabriel Tomitsuka
  • 1,121
  • 10
  • 24
  • Hi i just gave it a go sudo npm install node-siege -g, i had it installed before already. I can see the folder, but when i run siege -c10 -t1M http://localhost:3000 it gives me -bash: siege: command not found, even when i just opened terminal, and do siege -g http://www.google.com it still says -bash: siege: command not found – John May 10 '15 at 17:39