11

I am trying to setup NodeJS on EC2.

I followed the official guide and it was successful on my local machine. However when compile the source code on EC2, it takes forever to finish (2 hours and counting). I guess it has something to do with CPU limit or timeout.

I am not familiar with Linux and makefiles. Is there a way to bypass that? Thanks,

2
  • Can you execute "ps ux" in the EC2 machine to see what processes are running with the local user? It might give a clue to where it stopped compiling. Commented Nov 6, 2011 at 2:14
  • I have compiled Node on my EC2 micro instance 5-6 times and it never takes more than 10-12 minutes each time. Commented Nov 6, 2011 at 2:57

3 Answers 3

15

I'm guessing you're using a micro instance. Yep, it's going to take a while - micro instances get lots of CPU for a short while, then get severely capped if you use CPU for a while. Compiling node.js is CPU intensive.

On the bright side, you only have to do it once. Once it's finished, make an AMI and you can launch as many servers with node.js pre-installed as you like.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. But the compiling seems never ends. I guess I will switch to PHP. I will put off NodeJS when it becomes stabler that I can apt-get it.
Sounds like it locked up, then. It's plenty stable, just new enough that it isn't in the main repos yet. I've compiled node on an EC2 micro several times.
Hi ceejayoz. I tried to build one last time with the parameter "&" and it worked! I didn't get locked this time. Thanks for the help.
1

Wich distro are you on? I'am using ubuntu 10.04 LTS (ami-ad36fbc4 on a t1.micro)

I have a zip with a precompiled version of nodejs, this make me able to skip the compilation time the next time i need it!

Run this script as root, or put in the userdata field.

#!/bin/bash apt-get update -y apt-get upgrade -y apt-get install -y \ git-core build-essential \ openssl \ libssl-dev \ zip \ --fix-missing git clone http://github.com/joyent/node.git && cd node git checkout v0.4.12 ./configure JOBS=2 make cd zip -r node-v0.4.12-c.zip node git clone http://github.com/isaacs/npm.git && cd npm git checkout v1.0.104 && make install cd ../ rm -rf npm rm -rf node mkdir s3-uploader && cd s3-uploader npm install knox cat < uploader.js >> EOF var knox = require('knox'), fs = require('fs'); var client = knox.createClient({ key: 'S3_API_KEY' , secret: 'S3_API_SECRET' , bucket: 'S3_BUCKET_ID' }); fs.readFile('../node-' + process.version + '-c.zip', function(err, buf){ var req = client.put('node-' + process.version + '-c.zip', { 'Content-Length': buf.length , 'Content-Type': 'text/plain' }); req.on('response', function(res){ if (200 == res.statusCode) { console.log('saved to %s', req.url); } }); req.end(buf); }); EOF node uploader.js 

you can terminate the first server and the next time you run the same instance you have to put in your instance userdata this one, and skip the compilation.

#!/bin/bash wget –O node-v0.4.12-c.zip https://s3.amazonaws.com/[your-bucket-name]/node-[your-nodejs-version]-c.zip unzip node-[your-nodejs-version]-c.zip cd node make install cd ../ rm -rf node rm -rf node-[your-nodejs-version]-c.zip 

3 Comments

hi kilianc, how can I get a compiled NodeJS? I ran the make command locally then uploaded to S3 like you did. When I try to "make install" on the server, it gave err message.
you should compile and upload from remote! you need an S3 bucket, and a t1.micro ubuntu instance. You must compile nodejs on the same AMI you will use it. Try to compile from a large instance, it will take about 3/4 minutes. Which distro you're playing on?
It was a Ubuntu AMI. Then I made my private AMI and restarted so I don't have the original id of it.
0

If you are using aws free tier it's going to be like that as it provide very less resources

Pro Tip:- if you want to build faster please stop the instance(Only for learning purpose i assume) as it will stop databases and other services like nginx and will free up some resources and again start the instance then run build also if you have already setup your DNS the you have to setup again if you are not using elasticIP

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.