background preloader

Scaling Isomorphic Javascript Code

Scaling Isomorphic Javascript Code
Whether your using Angular, Ember.js, BigPipe or any other framework, all have dealt with seperation of concern issues. Today an increasing number of frameworks are adopting patterns that are similar on both client and server side. Chosing the right framework for the problem at hand is tricky, try them all on our platform for free, sign up now. Take a minute and think about how often you've heard the phrase "Model-View-Controller" (or MVC). Do you really know what it means? At a high-level it is about a separation of concerns between the major areas of functionality in presentation-centric applications built on retained graphics systems (i.e not-raster graphics, such as games). This approach has been acceptable for other languages such as Java, Ruby, and Python it is simply not good enough for Node.js for one reason: Javascript is now an isomorphic language. Design patterns are the bread and butter of application development. Figure 1: Model-View-Controller Lets dig deeper. Related:  nodejs

Submodules It often happens that while working on one project, you need to use another project from within it. Perhaps it’s a library that a third party developed or that you’re developing separately and using in multiple parent projects. A common issue arises in these scenarios: you want to be able to treat the two projects as separate yet still be able to use one from within the other. Here’s an example. Git addresses this issue using submodules. Starting with Submodules We’ll walk through developing a simple project that has been split up into a main project and a few sub-projects. Let’s start by adding an existing Git repository as a submodule of the repository that we’re working on. $ git submodule add Cloning into 'DbConnector'...remote: Counting objects: 11, done.remote: Compressing objects: 100% (10/10), done.remote: Total 11 (delta 0), reused 11 (delta 0)Unpacking objects: 100% (11/11), done.Checking connectivity... done. Pulling in Upstream Changes

Horizontally Scaling Node.js and WebSockets with Redis - GoldFire Studios The Node.js cluster module is a common method of scaling servers, allowing for the use of all available CPU cores. However, what happens when you must scale to multiple servers or virtual machines? That is the problem we faced when scaling our newest HTML5 MMORPG. Rather than trying to cluster on a single machine, we wanted to get the benefit of a truly distributed system that can automatically failover and spread the load across multiple servers and even data-centers. We went through several iterations before deciding on the setup outlined below. We'll be running through a basic example app, which is more general-purpose than some of the custom systems we built for massively multiplayer gaming, but the same concepts apply. OverviewWe began by defining the structure of our new stack before selecting the specific pieces -- that is secondary. If you've had any experience setting up distributed systems, then you are probably used to a similar pattern.

SierraSoftworks/Iridium topliceanu/mongoose-gen krakenjs - Give your node.js express apps some extra arms Here's what a DDOS Attack Looks Like - Yaabot Ever wondered how a DDoS (Distributed Denial of Service) attack would look like? Here’s a visual interpretation – created by developed Ludovic Fauvet. The video above is a representation of an old DDoS attack on VideoLAN’s site. VideoLAN is the team that makes our beloved VLC player. A DDoS attack is a hugely popular form of attack – hacker group Anonymous is known to use it quite often in its attempt to deliver ‘justice’. The video was created using a tool called Lostalgia, which interprets and gives us page requests in the way we just saw in the video. By Shashank Bhardwaj Shashank is an entrepreneur, watch enthusiast, and wannabe investor. View all articles by Shashank Bhardwaj

Node.js clustering made easy with PM2 Introduction As you would probably know, Node.js is a platform built on Chrome's JavaScript runtime, gracefully named V8. The V8 engine, and hence Node.js, runs in a single-threaded way, therefore, doesn't take advantage of multi-core systems capabilities. Node.js cluster module Luckily enough, Node.js offers the cluster module, which basically will spawn some workers which can all share any TCP connection. How does it work ? Cluster module will set up a master and then fork your server app as many times as you want it to (also called a worker). How to use it ? The most basic example is the following : var cluster = require('cluster'); var http = require('http'); var os = require('os'); var numCPUs = os.cpus().length; if (cluster.isMaster) { for (var i = 0; i < numCPUs; ++i) { cluster.fork(); }} else { http.createServer(function(req, res) { res.writeHead(200); res.end("hello world"); }).listen(8080);} Of course, you can spawn as many workers as you wish. The PM2 way Built-in clustering