BoxLang: Our new JVM Dynamic Language made by Ortus! Check it out: https://www.boxlang.io

Add on server start URL to warm up the server

Description

The ability to specify one or more warm up URLs for CommandBox to fire after the server is started in order to warm up the server.  For now it's just a predicate handler that accepts

  • urls – array of URLs to hit (required)

  • requestStrategy – during warmup…

    • block URLS with 503

    • queue requests until the server is ready (at which point they will be processed)

    • allow requests to flood in before warmup is complete (default)

  • async -- fire warmup URLs one at a time, or all at once (default to true)

  • timeoutSeconds -- how long to wait for the warm up URLs (default to 60)

If async is false, the timeout is applied separately to each URL. So, each URL is given the full timeout. If async is true, the timeout simply begins when they are all fired and applies to all of them at the same time. When the timeout is reached, we don’t end the request. It will still load in the background, but if the requestStrategy is block or queue, we will no longer block or queue new traffic.

The queue size is 10,000 and cannot be changed right now. That means up to 10,000 requests can come into the server while it is warming up and be queued. Once the queue is full, a 503 status code will be immediately returned for any additional traffic, which is the same as the block strategy. The first 10,000 requests int he queue will still process once the server is warmed up.

You can do a simple single-URL setup, which doesn't block or queue by default like so. The example uses positional args and only has a single URL so the {} array notation is not needed.

{ "web":{ "rules":[ "warm-up-server( 'http://127.0.0.1:8080' )" ] } }

Or a more complicated setup with more than one URL and custom settings. This uses named params and has more than one URL, so we use the {} notation.

{ "web":{ "rules":[ "warm-up-server( urls={'https://cnn.com','http://www.google.com','http://127.0.0.1:8080/warmup.cfm?brad=wood'}, requestStrategy=queue, async=false, timeoutSeconds=10 )" ] } }

URls can also be a relative URI, and the default base URL for that site (the same as what we would use to open the browser) will be used to create the complete URL. This can be handy for a site with uses different ports or hostnames across environments.

{ "web":{ "rules":[ "warm-up-server( '/myfile.cfm?foo=bar' )" ] } }

Activity

Show:

Daniel GarciaOctober 19, 2021 at 3:17 PM

That’s a good point, but I think they can secure that initial call lots of ways If they need to (token security, IP, etc) and it gives them something they don’t currently have. Someone once told me that we don’t tell them how to code, we just give them options. grinning face with big eyes

Brad WoodOctober 19, 2021 at 3:11 PM

Yeah, I suppose. Perhaps that could be the workaround for anyone needing something special in the request. Of course, it doesn’t solve the issue if the initial URL also needs all of that, it just kicks the can down the road slightly smiling face

Daniel GarciaOctober 19, 2021 at 3:00 PM
Edited

Could you configure it to only hit one URL, and then it would be up to that endpoint to proxy additional calls if needed? That way if there are funky requirements for URLs (array of URLs, timeouts, auth, etc), it can be dealt within that one function.

Fixed
Pinned fields
Click on the next to a field label to start pinning.

Details

Assignee

Reporter

Fix versions

Priority

Sentry

Created October 19, 2021 at 2:56 PM
Updated January 28, 2025 at 7:06 PM
Resolved January 25, 2025 at 6:19 AM

Flag notifications