Skip to content

Building and Running OSRM on EC2

Karen Shea edited this page Feb 16, 2016 · 7 revisions

How to use this page

The page is a supplement to the existing site on Building OSRM [here](Building OSRM) and Running OSRM here

The EC2 Micro instance is running Ubuntu 12.04 LTS.

Setting up SWAP File for compiling OSRM

It can be problematic to run the compilation process of OSRM with less than one 1GB of Ram, which is the case for EC2 Micro instances. To remedy this problem, setup a SWAP partition on the instance, with the following commands.

sudo dd if=/dev/zero of=/swapfile bs=64M count=16
sudo mkswap /swapfile
sudo swapon /swapfile

It should be possible to remove the swap file with these commands

sudo swapoff /swapfile
sudo rm /swapfile

How to handle OSM maps

It was enough to have a 1 GB swap file for the build. However when working with the osm.pbf file of Denmark from geofabrik, An error occurred with the message 'out of memory'. Then increase the swapfile size to 2.1GB with this command.

sudo dd if=/dev/zero of=/swapfile bs=64M count=32

Remember to run the remove swap command before running the command above.

It is possible to run the routing server for denmark without a swapfile, but with just below 90 MB free memory on the micro instance.

I cannot guarantee that this will not give some extra charges, with regards to the number of I/O requests.

Second problem is an error with regards to Unsupported Locale, but the following commands fixes that problem.

sudo locale-gen en_US en_US.UTF-8
sudo dpkg-reconfigure locales
export LANG="en_US.UTF-8"
export LC_ALL="en_US.UTF-8"

The last problem is the well-known problem of the missing timestamp file, when starting the OSRM server. Here is a quick fix for missing timestamp file.

date +%s > denmark.osrm.timestamp

Now you should be up and running.