In my previous post, I showed you how you could set up graphite and statsd to enable collection and visualization of your application and system metrics. In this post I continue with showing you how to serve up your graphite webapp using gunicorn and nginx, and how you can run and monitor the various components using supervisord when you use Kinvey Backend as a Service (BaaS)

Serving your graphite webapp

The graphite webapp is built using django and comes with a built-in development web server that is useful for testing and to make sure it’s installed properly. However, for production purposes, you should be using something that’s more robust. I chose gunicorn, because it natively supports django, and it seemed relatively straightforward to install. I also decided to use nginx to proxy requests to gunicorn as well as serve static content.

Installing gunicorn

The gunicorn website lists several different ways that one can install gunicorn. The recommended approach for Debian/Ubuntu systems is to use system packages. There is even a PPA that is up to date with the latest stable releases. See for more information.

Configuring gunicorn and the graphite webapp

There are 2 ways you can configure gunicorn to run graphite. The first option is to create a config file (see: Alternatively, you can pass the options on the command line as well. For example:

    -u www-data -g www-data

Here, we are using the Django wrapper: gunicorn_django and telling it to:

  • switch worker processes to run as the www-data user and group
  • bind to the loopback interface on port 8080
  • log errors to /opt/graphite/storage/log/webapp/gunicorn.log
  • Start an application using the django settings file: /opt/graphite/webapp/graphite/

I opted to configure via the command line, which you will see shortly when I bring up supervisord.

Configuring nginx to proxy requests to the graphite webapp

Here’s an example nginx configuration that proxies requests to graphite.

 One ring process control system to rule them all


Upstart has been positioned as the de-facto means to starting/stopping services and supervising them, especially on Ubuntu systems.Unfortunately, I had some difficulty getting carbon-cache (the metric collection agent) to cooperate with upstart, and after a fruitless afternoon of trying to resolve this, opted to use supervisord instead, which I found very easy to set up and configure.

Upgrading to graphite 0.9.10

If you followed the install process I outlined in my previous post, upgrading to graphite 0.9.10 should be as simple as shutting down carbon-cache, graphite-web and running:

sudo pip install –-upgrade whisper carbon graphite-web

and then optionally re-creating, as per the release announcement.

If you run into problems starting carbon-cache that appear to be related to twisted, it may be due to a change in the way dependencies are handled for carbon. I was able to resolve this by removing my global installation of twisted:

sudo pip uninstall twisted

I recommend you upgrade to 0.9.10 as it provides several fixes, enhancements and performance optimizations over 0.9.9.

What I have detailed above is by no means an optimal production configuration, but it should help you get started on the road to one. There are a host of things that can be done by way of optimization, performance etc. that I have not covered. Hopefully I can shed some light on those in a future post.

I appreciate any feedback you may have – please feel free to use the comment form below or send an email to if you have any questions. Check out Kinvey Backend as a Service . We now also have a HIPAA compliant app cloud version.