<p>Use the health check capabilities to ensure that your instance is not in service before your custom program is ready.</p>

<p>If you have a classic ELB, you can point to an specific enpoint, for example, /health_check.php that performs the necessary checks in your application to ensure that your custom program is ready. Then, when a new instance is attached to the load balancer, it will perform the health check action that you have configured an expects a right behaviour of it. If not, the health check fails and will continue to perform new health checks in the configured intervals until instance become in service.</p>

<p>On best practice for web servers behind a load balancer, for example, is to add an specific endpoint that checks that all the necessary pieces for your application is running and in service, that is database, storage, caching processes or whatever you new or consider critical for your system.</p>

<p>The <a href="https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-healthchecks.html" rel="nofollow noreferrer">official AWS documentation</a> is very useful for this.</p>

<p>Hope this helps</p>

CC BY-SA 4.0
2019-02-28T22:59:59.407Z
2019-02-28T22:59:59.407Z
Juan Manuel Ruiz Fernández
<p>I have a problem I am trying to solve. When the auto scaling creates a new EC2 instance, the load balancer gets a positive health check result fairly quickly. However, the problem is that we have a custom application that runs when an instance starts and we do not want the instance attached to the load balancer until it has completed. So I need to find a way to make the load balancer wait until our custom application is finished running.  What is the best way to accomplish this?</p>

<amazon-ec2>
How to make Load balancer to wait for custom program to finish running?
James
# How to make Load balancer to wait for custom program to finish running?

(Asked by: username_0 on 2019-02-28)

I have a problem I am trying to solve. When the auto scaling creates a new EC2 instance, the load balancer gets a positive health check result fairly quickly. However, the problem is that we have a custom application that runs when an instance starts and we do not want the instance attached to the load balancer until it has completed. So I need to find a way to make the load balancer wait until our custom application is finished running. What is the best way to accomplish this?

**Tags:** amazon-ec2


---

## 1 answers

### Answer by username_1 on 2019-02-28. Score: 2 | Accepted answer

Use the health check capabilities to ensure that your instance is not in service before your custom program is ready.

If you have a classic ELB, you can point to an specific enpoint, for example, /health\_check.php that performs the necessary checks in your application to ensure that your custom program is ready. Then, when a new instance is attached to the load balancer, it will perform the health check action that you have configured an expects a right behaviour of it. If not, the health check fails and will continue to perform new health checks in the configured intervals until instance become in service.

On best practice for web servers behind a load balancer, for example, is to add an specific endpoint that checks that all the necessary pieces for your application is running and in service, that is database, storage, caching processes or whatever you new or consider critical for your system.

The [official AWS documentation](https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-healthchecks.html) is very useful for this.

Hope this helps


---

