Learn Docker With My Newest Course

Dive into Docker takes you from "What is Docker?" to confidently applying Docker to your own projects. It's packed with best practices and examples. Start Learning Docker →

lcurl Is a Script to Visit a Site Every X Seconds Using curl

lcurl-is-a-script-to-visit-a-site-every-x-seconds-using-curl.jpg

This could be handy to use while testing your deployment strategy to make sure you're able to perform zero downtime deploys.

Quick Jump:

While testing a new deployment strategy I wanted to make sure one of my web apps continued to return 200s while I was performing a rolling update in a Kubernetes cluster so I decided to create a little script that wraps curl.

It’s available at: https://github.com/nickjj/lcurl

Here’s an example of visiting https://example.com every 250ms for a max of 5 times:

lcurl https://example.com 0.25 5

Running the above command will produce this output:

200 | 0.069927s | 2021-12-11T08:47:00 | 1/5
200 | 0.063947s | 2021-12-11T08:47:00 | 2/5
200 | 0.060945s | 2021-12-11T08:47:01 | 3/5
200 | 0.068982s | 2021-12-11T08:47:01 | 4/5
200 | 0.066179s | 2021-12-11T08:47:01 | 5/5

The video below walks through the origin of the script, using it and also goes over how the script was created. It’s a pretty basic Bash script that uses curl under the hood.

# Demo Video

Timestamps

  • 0:17 – Going over what the script does
  • 0:47 – I used this script to help test performing a zero downtime deploy
  • 2:07 – A specific Kubernetes issue I came across with the AWS Load Balancer Controller
  • 3:25 – Demonstrating the script on the command line
  • 4:42 – This script is made for quickly monitoring HTTP status codes, not benchmarking
  • 5:08 – Going over the script’s implementation details
  • 8:07 – curl is the hero of this story
  • 10:53 – Installing the lcurl script
  • 12:11 – Briefly going over the FAQ in the README file

Reference Links

What are you going to use this script for? Let me know below.

Never Miss a Tip, Trick or Tutorial

Like you, I'm super protective of my inbox, so don't worry about getting spammed. You can expect a few emails per year (at most), and you can 1-click unsubscribe at any time. See what else you'll get too.



Comments