to warm upThe HubSpot Dev Team is constantly coming up with really small, but really helpful patterns for building web applications. One of the most flexible and powerful items has been the application warmup URL.

The story of the warmup URL goes back a few years to when we were starting to build out a deploy system for our code. We decided to run most applications on two or more identical EC2 instances and put a load balancer in front of them. It was easy to take a server off the load balancer and deploy new code. But when you shifted traffic back to that server, the first request was slow. Because the applications get requests at all times of day the first request was often a customer and the slowness was a bad user experience.

We investigated the slow requests and found that the intial lag was from the database connection pool setup. Once the connections were made and the pool set up, subsequent requests were performant. No amount of lazy-loading or multi-threading would be able to shorten this necessary step.

We quickly came up with the idea of a warmup URL with an action to execute a database query. The warmup URL is called from the deploy script, and the response is checked for a "success string". The success string tells us that the connection pool and query have completed and that the server is ready to start handling real requests. During a deploy we only return traffic to the server after the warmup URL is successful. If we get an error response, or no response, we stop the deploy and alert the developer.

Additionally, the warmup URLs have been useful for external monitoring. Once the app is up and running there is almost no overhead in hitting the warmup URL. Pointing Nagios or Pingdom at it allows us to have a constant health check on the application.

Do you have any simple or quick patterns that make your web applications awesome?

so-hiring

Recommended Articles

Join our subscribers

Sign up here and we'll keep you updated on the latest in product, UX, and engineering from HubSpot.

Subscribe to the newsletter