Making Your App Like a Better Post Office

So I’m still just piecing all this together, but the more I learn about Node.js, the harder it is to keep avoiding Knowing absolutely nothing about this technology, I decided to take some time today to learn about it (and, thus, share what I’ve learned!).

Here’s what I’ve got so far: is a wrapper client for WebSocket and similar options like Flash or iFrame, for browsers that don’t use WebSocket.

The secret behind (and WebSocket) is that they enhance real-time communication between multiple clients and the server.

Traditionally, the server connects to one client at a time: they connect, they communicate, and they disconnect. Then the server waits for the next connection. Think of it like going to the Post Office with only one clerk. You wait in line until it’s your turn. When the clerk is available, he will say, “Next!” You go up to the counter, hand over your package to be send, pick up the package that you’ve received, and leave. Then it’s time for the next customer. In this model, the clerk can only service one customer at a time. (Imagine if everyone jumped to the counter, asking for all their mail at once - it’d be chaos!)

Now, with, the server can connect to multiple clients at once, in real time. No more waiting in line, and no overwhelming the server. In our post office analogy, we’ve now got as many clerks as there are customers. The post office is still the single server, but each clerk is a socket. When a customer walks in, he doesn’t wait in line; he just goes straight to an available clerk. The customer connects with the clerk, sends/receives his packages, and leaves. Whether it’s one customer or two customers or a hundred customers, each one will get their personal clerk, connect, communicate, and disconnect.

When is useful? Basically when you’ve got a bunch of clients accessing the same server at once, and you want real-time events. Think of a chat room or Twitter. Everyone’s sending/receiving information at once, but you don’t want to wait for those connections to happen.

When is it unnecessary? If you don’t need a lot of real-time information, then don’t worry about it. So, if you’re building a website for your company, or an application that uses flashcards (and doesn’t need back-and-forth communication with everyone all at once), then don’t bother.

For CrowdNotes, however, is going to be absolutely necessary. I can’t wait to start implementing it!