I’ll be at VS Live in Las Vegas this March to discuss zero downtime deployments. If you want to come and join me for this session, or any of the other great ones, register today and save $500 with the promo code “Jones”. You can use this link to register.
To simulate the effects of deployments on a workload, I built a small client. It’s nothing great, and likely some of you will laugh at my C# skills, but it works well enough. It’s a simple Windows form application that writes to a text box. However, it’s valuable to determine if there are any issues when you’ve made a deployment.
This post looks at the rough design of the client. Code is available in this repo: https://github.com/way0utwest/ZeroDowntime
Using WPF
I wrote a small app a few years ago to test and present on Always Encrypted. This was a basic WPF app that added the proper values to the connection string for Always Encrypted and let you query encrypted data (or not).
Like all mediocre developers, I copied and pasted that project into a new folder and set about modifying it. In this case, I set up a loop that continues to run and execute some database code, essentially using this loop:
while (iRunQuery > 0) {
I set this value to 0 initially, and when a button is clicked, it’s 1. This then runs a bunch of lines to decide which DB code to run. I’ve mostly made this stored procedures to make it easier to adjust demos without touching C# code.
It’s not pretty.
At the bottom, I have this (outside the loop)
Application.DoEvents(); System.Threading.Thread.Sleep(100);
This is designed to catch me clicking a “stop” button that will set the variable back to 0. I added the delay because otherwise this runs a bit fast.
I have a few option buttons that adjust what code I’m calling, so I can simulate toggling feature flags on and off. I also log results to a window so you can see them, and I catch errors and log those. Errors are also counted, so we can see the impact of “non zero-downtime” changes.
It’s not a great example of software, but it does work.