Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

TL;DR - Is there a way to make nginx act as an elastic load balancer that will spin up EC2 instances on demand, allowing for the case when periods of no demand mean no instances will be running?

Longer explanation - I have an nginx server that proxy_pass'es requests to a server on EC2. This server doesn't get many requests, so I'd like to keep the server spun down during periods of inactivity (I already have a script to do this). Then, when the instance is spun down and nginx gets a request for that instance, it will time out when trying to get a response from it. At this point, can I somehow trigger a shell command on the server to use EC2's command line tools to spin up the instance, then re-try the user's request after it has started?

share|improve this question
    
Setting up an EC2 autoscaling group would make a lot more sense here. –  jamieb Dec 10 '12 at 10:47
    
@jamieb, can an autoscaling group be set up such that 0 servers is the normal case, and then it just spins up 1 server when the server is requested, then spins it down after some idle period? I saw auto-scaling, but thought that because it seems to depend on CloudWatch monitoring to decide when to increase/decrease instances, this would necessitate the presence of at least one server to begin with. What's the story here? –  Gabe Hollombe Dec 10 '12 at 22:57

1 Answer 1

You can script nginx with lua. This might make it possible to use it with the API Tools to spin up new instances.

share|improve this answer
    
I was thinking something along these lines might work. But I'm hoping for a specific "Yes, here's how..." style answer. –  Gabe Hollombe Dec 10 '12 at 2:59
    
Hmm, I've never see this done (I've seen examples with HAProxy in the past though using Nginx as a back-end server). Although you might be in better luck to use a scripting language like Python to determine this (LUA might not script well with EC2). –  Taylor Jasko Dec 10 '12 at 8:03

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.