Avoid OpenShift Application Idling
OpenShift is a great Platform-as-a-Service provided by Red Hat to host web applications in a cloud environment. I use OpenShift to host a few services, such as my iPhone Tracking service (details here).
The OpenShift free plan provides three small Amazon EC2 instances to use without a CPU, memory or bandwidth cap – this is perfect for running some of the small web applications I develop. However, the free plan also has a big limitation: if an application does not receive an HTTP request within 24 hours, it will be suspended.
Update January 2018: Since publishing this article, OpenShift have changed their free plan. You can find more information on their pricing page.
This limitation is fine if you are running a standard website. Once asleep, the next HTTP request will simply take a few seconds longer to respond as the EC2 instance is spun up. However, if you are running a web service that needs to perform a task at regular intervals, such as tracking the location of your mobile phone, then you do not want the application to idle.
To work around this limitation, you simply have to ensure an HTTP request is made to your service every 24 hours from outside of your EC2 instance. The best way I have found to do this is by registering the site with an “uptime checker”, such as UptimeRobot.
UptimeRobot makes an HTTP request to my web service every 5 minutes to check it is running. This is perfect for ensuring my OpenShift instance does not idle due to inactivity and also provides me with a monitoring service for my application.