CouchDB distribution and management of Node.js applications
Steelmesh is designed to assist with managing and scaling Node + Couch applications in a horizontal fashion. At this stage, Steelmesh is not designed to support partitioning large datasets, but rather to:
Provide load distribution for small-medium sized datasets that experience a high traffic load.
Provide a manageable interface to a number of Couch + Node instances.
OK. Just so you know, getting an instance of Steelmesh running is reasonably involved. Not too tricky, but it might involve some mucking around and the process is still nowhere near as refined as it will be in a few months...
Also, Sidelab will be running up a hosted installation of Steelmesh in the near future, so if you are feeling brave, then feel free to message me and we can look at providing you access once it's available.
Essentially, get an installation of CouchDB running somewhere on your network. I would recommend using one of the Couchbase distributions as they are just lovely to work with.
If you don't already have Node and NPM running, then you will need to install them. Use google - it's your friend.
To aid in both creating steelmesh apps, and also administering a steelmesh server we have some command-line tools. The simplest way to install these tools is via npm:
npm install mesh -g
Once installed, this will provide you a
mesh command line utility.
By default, steelmesh will attach to a CouchDB called
steelmesh. This database is not automatically created, so you will need to use the mesh command line tools to create it. Run the following command to initialize the db:
This should generate something similar to the following:
Preparing.Serializing.PUTFinished push. 1-385253ac3b0c205f93dafee1d839751d>> mesh:admin-create- _design/defaultOperation succcessful
This command creates the steelmesh database and uploads the required design documents into the database.
OK, you've made it this far. Nice job. Now, in a location that you would like to run steelmesh, clone this repository:
git clone git://github.com/steelmesh/steelmesh.git
Once you have cloned the repository, change into your newly created directory and pull down the required node_modules:
Once the required modules are you should be able to run the following command:
All being well, you should see output similar to the following:
loading apps using the couch apploadersynchronized application resourcesinfo - master startedinfo - worker 0 spawnedinfo - worker 1 spawnedinfo - listening for connectionsinfo - worker 1 connectedinfo - worker 0 connected
This is a mix of some steelmesh output and output that has been generated from cluster.
At this stage, steelmesh is operational, but not doing a lot. Time to create an app.
Now, create a directory somewhere on your local machine. By default, the name of the folder will become the name of your Steelmesh appliation but that can be changed using the various Configuration Options. Anyway, let's create an application. I'm going to create a directory called test (because I'm creative like that):
mkdir testcd testmesh create
Now in the test directory, you should see a number of new files, including an app.js file. The app.js file is basically the file that contains the information on how the application controls routes, background tasks that it does, etc, etc. Lots of documentation coming on this... promise.
One the application has been created, you can publish the application to a Steelmesh server using the following command:
This would generate output similar to the following:
Preparing test for deploymentPushing to db...Preparing.Serializing.PUTFinished push. 1-f0ee9c0a7e63e35207220559cf35390eOperation succcessful
Now that you have pushed the application to the steelmesh, restart the steelmesh server (see Step 7).
NOTE: This is a temporary step that is required while we are properly implementing listening to CouchDB change notifications and auto reloading updated applications.
You should now see the following when the server is started:
no configuration file, using default configloading apps using the couch apploadersynchronizing application: testsynchronized application resourcesinfo - master startedinfo - worker 0 spawnedinfo - worker 1 spawnedinfo - listening for connections
By default, Steelmesh is designed to run behind nginx as this provides an ideal front-door to both CouchDB and Node. So if you don't have nginx installed already, then go get it...
Before we test our application, we will need to start nginx to act a reverse-proxy to both our CouchDB server and Node server. Steelmesh comes with a prebuilt nginx configuration that routes traffic to the appropriate destination.
The simplest way to start nginx is by changing to directory you installed steelmesh in and running the following command:
sudo nginx -p nginx/
This tells nginx to use the
steelmesh/nginx directory as the nginx root, so the configuration file is loaded from the
conf directory automatically. NOTE: The
sudo command is required as the configuration by default listens on port 80 and binding to ports below 1024 (I think) requires superuser privileges.
If everything has gone well, then you should be able to view the following url (if you are running locally, and called your application is called
Out of the box, Steelmesh is basically Express on NodeJS with CouchDB connectivity. Express (via Connect), however, offers very powerful middleware capabilities and as such some addins are being developed for Steelmesh:
Steelmesh is distributed under the Apache License (v2).