Deployment Probes - A deep dive
Probes are an essential tool for ensuring that your application is running smoothly on Patr. When your application is updated, it's often necessary to restart it, which can lead to downtime for your users. Downtime can be frustrating for users and can even lead to lost revenue for your business. With probes, however, you can avoid downtime and ensure that your application is always available to your users.
Types of Probes in Patr
When it comes to probes, we offer two types: startup probes and liveness probes. By using both types of probes, you can ensure that your application is always available to your users.
A startup probe is used to determine when an application is ready to start receiving traffic. When you first deploy an application, it might take some time for it to fully initialize and start listening to incoming requests. A startup probe allows you to specify a URL that Patr will hit repeatedly until it receives a successful response. Once the startup probe succeeds, Patr knows that the application is ready to receive traffic and will start sending requests to it. If the startup probe fails, Patr will wait for the container to initialize and try again.
On the other hand, a liveness probe is used to determine whether an application is still running and responding to requests. Once an application is up and running, it is important to ensure that it remains responsive and available to users. A liveness probe allows you to specify a URL that Patr will hit at regular intervals to make sure that the application is still running. If the liveness probe fails, it indicates that the application is no longer responding and may be in a bad state. Patr will then restart the container and try to bring the application back up to a healthy state.
How Probes work internally
Both startup and liveness probes work by sending an HTTP request to the specified URL and waiting for a response. If the response code is 200, it is considered a success and the probe is considered to have passed. If the response code is anything other than 200 (such as a 404 or 500), it is considered a failure and the container is marked as unhealthy. Depending on the configuration, Patr may then restart the container or take other actions to remedy the situation.
By using startup and liveness probes, you can ensure that your application is always running and ready to handle incoming requests. This is especially important when deploying updates or changes to your application, as it allows you to do so with zero downtime. For example, if you update your application and it requires a restart, a startup probe can be used to ensure that the new version is fully initialized and ready to receive traffic before Patr starts sending requests to it. Similarly, a liveness probe can be used to ensure that the updated application remains responsive and available to users.
Setting up probes
In order to add a probe, navigate to the Manage Deployment screen of your Deployment, and scroll to the Startup Probe and Liveness Probe section.
Select a port of the application that you have exposed, and a path that you would like the probe to access. For example, if you choose your port to be 3000 and the path to be
/healthz, Patr will make a HTTP request to port 3000, with the path
/healthz. If Patr receives a 200 OK response, then the probe is marked as successful.
When to use Probes
By using probes, you can ensure that your application updates are seamless and that there is zero downtime for your users. This is especially important for applications that have a large number of users or that are critical to your business operations. With probes, you can deploy updates with confidence, knowing that your application will remain available and responsive to your users.
In conclusion, probes are an essential tool for ensuring that your application is always available to your users. By using startup and liveness probes, you can ensure that your application starts up correctly and remains running correctly, even after updates or changes to your application. By leveraging the power of probes, you can provide a seamless experience for your users and avoid downtime, which can be costly and frustrating for your business.