Skip to content

Commit 1274ff3

Browse files
WIP of a full rewrite
1 parent 9750f58 commit 1274ff3

File tree

5 files changed

+72
-22
lines changed

5 files changed

+72
-22
lines changed
39.4 KB
Loading
784 KB
Loading
-99.6 KB
Loading
-29 KB
Loading

site/content/guides/canary-deploys.md

Lines changed: 72 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,84 @@ Canary deployments are one of the ways we can release updates without violating
1212

1313
## Why We Need Canary Deployments
1414

15-
All teams that prioritize reliability will perform testing to make sure code works before it's deployed to real users. However, at a certain point we must admit that some problems can't be predicted by pre-release testing, no matter how complex. Canary deployments help limit the scope of unforeseen failures on production.
15+
All teams that prioritize reliability will perform testing to make sure code works before it's deployed to real users. However, at a certain point we must admit that some problems can't be predicted by pre-release testing, no matter how complex. Canary deployments help limit the scope of unforeseen failures on production. Let's take an example for our guide: a major change to our eCommerce store with a significant rewrite of our front-end code.
16+
17+
![a comparison of two storefronts](/guides/images/canary-deploy-bad-deployment.png)
18+
*The canary deployment in our example is a total redesign of our storefront, and along with existing features a number of features will be added.*
1619

1720
![a diagram of a canary deployment](/guides/images/canary-deploy-step1.png)
18-
*The first stage of a canary deployment: after rolling out new code to a subset of servers, some users are moved over to the new code version. Most users see the previous, known good, 'current' version of our service, while some see the updated 'canary' version. Note that canary deployments work in a number of ways, possibly assigning users randomly, and a simple page reload may switch the version a user sees.*
21+
*The first stage of a canary deployment: after rolling out new code to a subset of servers, some users are moved over to the new code version. Most users see the previous, known good, 'current' version of our service, while some see the updated 'canary' version.*
1922

20-
Once the canary version of the service is shown to be working well, all users can be transferred over to the new version.
21-
![a diagram of a canary deployment](/guides/images/canary-deploy-step2.png)
23+
Note that canary deployments work in a number of ways, possibly assigning users randomly at the database level, or a simple page reload may switch the version a user sees. Users assigned to a canary server will often receive a feature flag via a header that will cause their requests to be routed to canary servers.
2224

23-
The essential problem we're trying to solve with this guide is **how do you know that your canary deployment is working?** Often the tools available to operations teams are quite limited, and amount to little more than a smoke test. Since canary servers are tagged at the infrastructure level, operations can see the infrastructure health of canary servers, but not their actual performance for users. Let's look at an example:
25+
Canary deployments let us ensure that the new version of our site is working before all users see it. While canary deployments are valuable for incrementally rolling out new features and updates to users, they present a special challenge for synthetic monitoring, especially in scenarios like the one above where the user interface is changing: *how can an automated monitor that checks the user interface succesfully check an interface that's being served in two separate versions?* The rest of this guide will show you how to create checks that can check two different versions of your site based on whether they detect a feature flag at runtime.
2426

25-
![a comparison of two storefronts](/guides/images/canary-deploy-bad-deployment.png)
26-
*During a deployment, our feature flag loads our new chat feature, but the API also isn't returning full data, so our book catalog looks incomplete.*
27+
### What if we're not setting a feature flag?
28+
29+
The process defined above starts with checking the response headers for a feature flag, but not every canary deployment will be engineered in the same way. Is it possible to detect that the test is running against a canary server even without a header to match? Absolutely! The test above just has to be modified to look for any detail that indicates we're looking at the canary version of the site. Looking at our new site interface:
30+
![a new website](/guides/images/canary-deploy-new-site.png)
31+
We can look for any detail of the page to recognize that we're on the canary version, for example the 'Electronics' button on the new page.
32+
33+
```typescript
34+
import { test, expect, Page, Locator } from '@playwright/test'
35+
36+
test('Canary deployment detection based on UI elements', async ({ page }: { page: Page }) => {
37+
await page.goto('https://danube-web.shop')
38+
39+
// Check if Electronics button is visible (indicates canary version)
40+
const electronicsButton: Locator = page.locator('button:has-text("Electronics")')
41+
const isElectronicsVisible: boolean = await electronicsButton.isVisible()
42+
43+
if (isElectronicsVisible) {
44+
// Canary version detected - test new functionality
45+
await expect(electronicsButton).toBeVisible()
46+
await electronicsButton.click()
47+
48+
// Test canary-specific features
49+
await expect(page.locator('.category-electronics')).toBeVisible()
50+
await expect(page).toHaveTitle(/Electronics/)
51+
52+
console.log('✅ Canary version detected and tested')
53+
} else {
54+
// Production version - test existing functionality
55+
const productionButtons: Locator[] = [
56+
page.locator('button:has-text("Books")'),
57+
page.locator('button:has-text("Clothing")'),
58+
page.locator('button:has-text("Home & Garden")')
59+
]
60+
61+
// Verify at least one production button exists
62+
let foundButton: boolean = false
63+
for (const button of productionButtons) {
64+
if (await button.isVisible()) {
65+
await expect(button).toBeVisible()
66+
await button.click()
67+
foundButton = true
68+
break
69+
}
70+
}
71+
72+
expect(foundButton).toBe(true)
73+
console.log('✅ Production version detected and tested')
74+
}
75+
})
76+
```
77+
78+
## Further Reading
79+
80+
**Checkly Guides:**
81+
- [Getting Started with Monitoring as Code](https://www.checklyhq.com/guides/getting-started-with-monitoring-as-code/) - Learn the fundamentals of programmatic monitoring that make canary deployment strategies scalable
82+
- [Detect, Communicate, and Resolve with Checkly - A Step-by-Step Tutorial for Engineers](https://www.checklyhq.com/guides/startup-guide-detect-communiate-resolve/) - Discover how monitoring as code enhances developer workflows and deployment confidence
83+
- [Scaling Your Monitoring Setup Beyond the UI](https://www.checklyhq.com/guides/scaling-your-monitoring-setup/) - Explore techniques for managing complex monitoring requirements as your deployment strategies evolve
84+
85+
**Checkly Learn:**
86+
- [Monitoring](https://www.checklyhq.com/learn/monitoring/) - Deep dive into monitoring strategies and best practices for deployment validation
87+
- [Playwright Testing](https://www.checklyhq.com/learn/playwright/) - Master browser automation techniques used in the canary deployment examples
2788

28-
Looking at simple infrastructure metrics won't reveal this problem.
2989

30-
![an infrastructure metrics chart](/guides/images/canary-deploy-graph.png)
31-
*A chart like this one showing network operations can at least show that the canary servers are running and accepting requests, but it's hardly an accurate picture that everything on the service is working as designed.*
90+
91+
# unused
92+
----
3293

3394
## How Synthetic Monitoring Can Improve Canary Deployment Reliability
3495

@@ -386,15 +447,4 @@ This guide demonstrated three complementary approaches to enhance your canary de
386447
387448
Together, these techniques transform canary deployments from a "hope and pray" exercise into a confident, data-driven process. Your team gains the ability to **detect** issues faster with targeted monitoring, **communicate** deployment status clearly with dedicated dashboards, and **resolve** problems before they affect all users.
388449
389-
The monitoring-as-code approach makes these enhancements scalable and repeatable, ensuring every canary deployment benefits from the same level of observability and control.
390-
391-
## Further Reading
392-
393-
**Checkly Guides:**
394-
- [Getting Started with Monitoring as Code](https://www.checklyhq.com/guides/getting-started-with-monitoring-as-code/) - Learn the fundamentals of programmatic monitoring that make canary deployment strategies scalable
395-
- [Detect, Communicate, and Resolve with Checkly - A Step-by-Step Tutorial for Engineers](https://www.checklyhq.com/guides/startup-guide-detect-communiate-resolve/) - Discover how monitoring as code enhances developer workflows and deployment confidence
396-
- [Scaling Your Monitoring Setup Beyond the UI](https://www.checklyhq.com/guides/scaling-your-monitoring-setup/) - Explore techniques for managing complex monitoring requirements as your deployment strategies evolve
397-
398-
**Checkly Learn:**
399-
- [Monitoring](https://www.checklyhq.com/learn/monitoring/) - Deep dive into monitoring strategies and best practices for deployment validation
400-
- [Playwright Testing](https://www.checklyhq.com/learn/playwright/) - Master browser automation techniques used in the canary deployment examples
450+
The monitoring-as-code approach makes these enhancements scalable and repeatable, ensuring every canary deployment benefits from the same level of observability and control.

0 commit comments

Comments
 (0)