Heroku app is slow? How to increase performance with Django and S3

My django app on Heroku runs starts up really slowly.

I run a simple django application that is hosted on Heroku and I use s3 to serve my static and media files.

My initial load ‘First View’ time would climb to almost 15seconds which is unacceptable. From then on it would speed up but still some tweaks were in order.

I ran my website through http://www.webpagetest.org and landed up scoring four F symbols for

  1. Cache static content [F]
  2. Keep-alive Enabled [F]
  3. Compress Transfer [F]
  4. First Byte Time [F]

Here is what I did to help speed up my site.

Continue reading

How to install current stable nodejs on Ubuntu

I wanted to install nodejs on my Ubuntu isntall (13.04) but the repos only held quite an old version 0.6. With some Google help I ran into https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager#ubuntu-mint

Just follow these instructions and you’ll have nodejs current stable running in no time.

sudo apt-get update
sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs

django.core.exceptions.ImproperlyConfigured: ‘django.contrib.gis.db.backends.postgis’

I pulled down a GeoDjango application today and ran into this issue.

django.core.exceptions.ImproperlyConfigured: ‘django.contrib.gis.db.backends.postgis’ isn’t an available database backend.
Try using django.db.backends.XXX, where XXX is one of:
‘dummy’, ‘mysql’, ‘oracle’, ‘postgresql_psycopg2’, ‘sqlite3’
Error was: No module named psycopg2.extensions

If you run into this error just follow the steps and hopefully you’ll be on your way in no time.
Continue reading

Setting up GeoDjango on Ubuntu

This is how I setup GeoDjango development environment on a clean install of Ubuntu.

A good place to start would be to take a quick look at the docs but don’t spend to much there. Just follow on 🙂

Hopefully you already have Django setup on your machine. If not you’ll have to do so and can follow my Django setup guide here

In a nutshell we will:

  1. Install a Geospatial Library (PostGIS)
  2. Setup a Geospatial database template (Using a script)
  3. Create a database to test Continue reading

Setting up my django environment for Ubuntu

This is how I setup my django development environment on a clean install of Ubuntu.

Moving right along, on a  clean Ubuntu 12.04 install:

  1. Synaptic Package Manager

Once installed open Synaptic Package Manager, find and tick the following programs:

  1. postgresql (9.1 in this case)
    • mark all additional changes
  2. I also check postgresql-server-dev
    • mark all additional changes
  3. Check pgadmin3
    • mark all additional changes
  4. virtualenvwrapper
    • mark all additional changes (make sure python-virtualenv and python-pip are checked)

Now hit Apply and install everything you just marked.

Open your terminal and now you can type:

mkvirtualenv myvenv

You should see this:

mkvirtual

mkvirtual

Continue reading

You do not have the permissions necessary to view the contents of ‘shared_folder’

I develop within Virtualbox(VB). Often I need to be able to share files and folders between my host machine(the machine VB is installed on) and my client machine(the OS installed in VB, in this case Ubuntu).

It’s easy to share a folder. If you follow these steps:

1) Open Virtualbox, select your OS on the left then click on Shared Folders on the right.

Continue reading

SSH keys for GIT and HEROKU

Install git by typing

sudo apt-get install git

Then lets install Heroku toolbelt by typing this in

wget -qO- https://toolbelt.heroku.com/install.sh | sh

Both git and heroku use SSH keys. I always backup my SSH keys by backing up my “.ssh”  folder in my home directory. You can then copy this folder back to any new Ubuntu installation you have and you won’t have to regenerate your SSH keys! Win! If you need to generate a new SSH key then just follow the instructions here:  Continue reading