Tell me more ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Part I - The Story:

I have crafted a high performance TCP server in C# (based on SocketAsyncEventArgs) which works brilliantly (for my cause). I have more than 7000 clients, sending me a message every 30 sec - 1 min.

In the past days I was studying Node.JS (for another, totally unrelated project) and I have learnt that Node.JS could be used as a TCP server. So I thought: "Heh...Let's see if it can compete with my 'state of the art' TCP server".

And it was astonishing how Node.JS was (is) more performant (in some cases far more performant) than that "state of the art TCP server" and was far simpler and used far less resources.

Part II - The Question:

Is it right to use Node.JS just for implementing a TCP server and not a web app? Does that considered as abusing Node.JS? And if anybody had did that what were the pros and cons in the long run?

Note (an important one): I have not implemented the message parsing part in Node.JS yet. So I must find a performant way to implement heavy-lifting in an async manner.

share|improve this question
This is precisely the type of task Node.JS was made for. That said, you asked a pretty poor question "Have you done X? What were the pro's and cons?" There's no correct answer to that question, voting to close, when you edit Part II to have a clear answerable question it may be reopened (if it get's closed) so don't fret, just fix. – Jimmy Hoffa Jun 21 at 6:01
1  
Also do some research, Node.JS isn't magic, it's approach to this stuff can be seen in Erlang and Haskell before it, likely others as well. After many years of C# development I have decided; C# is a poor language for server work. Other languages came before with a focus on writing services and do things like this much better. Though that's pure opinion and non-sense in the eyes of many of my peers.. – Jimmy Hoffa Jun 21 at 6:04
Haskell: If one ever succeed to write anything in this language that compiles; he does not need to check anything else! Find a Haskell developer. Erlang: Meh...Ugly but not so bad, MP style sounds good but again: Find a developer. C# is great; even after many years (from .NET 1, 2002) and it makes things "done"; not as beautiful as F#; but .NET == C#. I ask this question because I think Node.JS meant to solve problems in development of a web application and (IMHO) this kind of usage (maybe) is abusing it. To make sure I am not doing something horribly stupid I should turn to veterans. – Kaveh Shahbazian Jun 21 at 6:21
And the only other thing that got my attention (comparable to Node.JS) this deeply is Go. I had never developed a real world app in a dynamic language (other than JavaScript in browser and some Windows batch and PowerShell; those that was just relatively small parts of big apps). So writing something in a dynamic language always was like magic to me. I always thought "These guys should be more than just lucky that write things in a dynamic language and it works. They might be geniuses!" and it was a unique experiment for me to write an app (server-side) in JavaScript! Works better than C#?!!! – Kaveh Shahbazian Jun 21 at 6:28
With the years of C# you have then you remember that originally WinForms was probably the biggest grab and goal of C#. ASP.Net was an after thought and a disaster to begin with, which they inched better over time to having fairly decent HTTP facilities, but still having played in other languages I've concluded that the ones which were made for service development from the get go show a distinguished amount of maturity over C# in that area. Go is another good choice for this sort of thing. I agree about Erlang, but this type of work is what it's for. Node.JS as well; really, not just web dev. – Jimmy Hoffa Jun 21 at 14:25
show 1 more commentadd comment (requires an account with 50 reputation)

closed as not constructive by Jimmy Hoffa, Kilian Foth, Glenn Nelson, Dynamic, Jalayn Jun 21 at 13:07

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

2 Answers

What were the pros and cons in the long run?

  1. Scalability; does node.js perform well when you want to distribute the server to several nodes?
  2. Moving to cloud; how well is node.js supported by cloud vendors?
  3. Security.
share|improve this answer
2 & 3 are not of my concern (for this project). About 1 I am seeing into employing load balancing (did not came up with a conclusion yet). – Kaveh Shahbazian Jun 21 at 17:25
add comment (requires an account with 50 reputation)

As Jimmy Hoffa has said, the reason Node.js performs so well is down to its architecture. If you want something that performs even better, you can have a 'better' language but must still use it in the same architectural way. So try a server written in Erlang and see how you go, or try Microsoft's newest research in Casablanca (now known as the "C++ REST SDK") that was designed to scrape as much performance out of server/cloud systems as possible.

I think the biggest issue you'll have for async-style servers written in Node.js is the complexity of handling all the callbacks. Languages like Erlang have language features that make this easier (as does C++ 0x11 which is maybe why MS based Casablanca on it). As the number of calls and module you add to your system, especially where they interact with each other, you might find things start to get quite messy.

share|improve this answer
Yeah the fact that Node.JS is entirely written in continuation passing style when languages like Erlang, Go, Haskell, and likely others have shown there are ways you can handle asynchrony while avoiding a mess of CPS is the biggest detractor in my mind for Node.JS, it's the lazy way to deal with blocking IO for the runtime, rather than the runtime figuring out when it can context switch and what comes next it demands the developer explicitly define every blocking call and what comes next. – Jimmy Hoffa Jun 21 at 19:03
add comment (requires an account with 50 reputation)

Not the answer you're looking for? Browse other questions tagged or ask your own question.