<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Panos Angelopoulos</title>
    <description>The latest articles on DEV Community by Panos Angelopoulos (@railflag).</description>
    <link>https://dev.to/railflag</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4255684%2F18d6b495-39f6-471c-be67-abc782e2cb22.png</url>
      <title>DEV Community: Panos Angelopoulos</title>
      <link>https://dev.to/railflag</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/railflag"/>
    <language>en</language>
    <item>
      <title>Kill switches: turn features off in seconds, even at 3 a.m.</title>
      <dc:creator>Panos Angelopoulos</dc:creator>
      <pubDate>Fri, 20 Nov 2026 12:38:14 +0000</pubDate>
      <link>https://dev.to/railflag/kill-switches-turn-features-off-in-seconds-even-at-3-am-o34</link>
      <guid>https://dev.to/railflag/kill-switches-turn-features-off-in-seconds-even-at-3-am-o34</guid>
      <description>&lt;p&gt;When a feature or a dependency starts hurting production, the fastest fix is to turn it off, without waiting for a rollback. Here's how to build a kill switch that still works at 3 a.m., when part of your infrastructure is already down.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;kill switch&lt;/strong&gt; is a long-lived &lt;a href="https://railflag.com/feature-flags?utm_source=devto&amp;amp;utm_medium=social&amp;amp;utm_campaign=kill-switch" rel="noopener noreferrer"&gt;feature flag&lt;/a&gt; that turns a feature or a dependency off at runtime, without a deploy. During an incident, an engineer flips it to stop the damage in seconds, then fixes the cause without time pressure.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why a kill switch beats a rollback
&lt;/h2&gt;

&lt;p&gt;A rollback redeploys the previous version: build, deploy, warm-up, often 10 to 30 minutes, and it also removes every other change in the release. A kill switch changes one behaviour, reaches every instance within seconds, and is just as easy to undo. It also works for problems a rollback cannot fix, such as a third-party API that started failing on its own.&lt;/p&gt;

&lt;h2&gt;
  
  
  When you need one
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Third-party dependencies:&lt;/strong&gt; a payment provider, a recommendations API, a search cluster, an LLM call. When it slows down, your requests slow down with it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Expensive work:&lt;/strong&gt; a heavy query, a report export, image processing. Under load, shedding it keeps the core product up.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;New code paths in risky areas&lt;/strong&gt; such as checkout, sign-in or billing, for the first weeks after launch.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Background jobs and integrations&lt;/strong&gt; that can flood a downstream system: email sends, webhooks, syncs.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Non-essential UI:&lt;/strong&gt; a chat widget, a banner, personalised sections that call extra services.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  How to implement a kill switch
&lt;/h2&gt;

&lt;p&gt;A kill switch is a boolean flag that defaults to &lt;em&gt;on&lt;/em&gt;: the code default is the feature running, and the switch turns it off. Here it is with an &lt;a href="https://openfeature.dev" rel="noopener noreferrer"&gt;OpenFeature&lt;/a&gt; client, but any flag SDK looks the same:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// true = the recommendations service is called. Flip to false to shed it.&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;recommendationsOn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;flags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getBooleanValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s1"&gt;'recommendations-enabled'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;context&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="n"&gt;recommendations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;recommendationsOn&lt;/span&gt;
  &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;recommendationsApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="n"&gt;timeout&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;800&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
  &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// the degraded but working path&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Four rules make the difference between a switch that works and one that doesn't:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;The off path must be boring.&lt;/strong&gt; Return an empty list, a cached value or a static message. If turning the feature off calls another fragile service, the switch moves the problem instead of stopping it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Default to the feature running.&lt;/strong&gt; If the flag system can't answer, the code default is used. For a kill switch, that should be normal operation, not an accidental outage.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Evaluate locally.&lt;/strong&gt; Incidents often involve network trouble. A server SDK that holds the rules in memory keeps answering, and keeps the last known value, even if it can't reach the flag service. A switch that needs a network call per check can fail exactly when you need it.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Check it at the right place.&lt;/strong&gt; Put the check where the cost is: before the outbound call or the expensive query, not in the UI that displays the result.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  How granular should a kill switch be?
&lt;/h2&gt;

&lt;p&gt;One switch per dependency or per feature is the usual sweet spot. A single "maintenance mode" switch is too coarse: it turns off everything to stop one thing. One switch per endpoint is too fine: nobody remembers which to flip. Targeting rules let one switch be precise when it needs to be, for example off only for one region, one customer or one platform while you investigate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Test it before the incident
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Test both paths in CI:&lt;/strong&gt; run the code with the switch on and off.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flip it in staging regularly,&lt;/strong&gt; and in production during a quiet period if the off path is customer-safe. A switch that has never been flipped is a hypothesis.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Measure how long it takes&lt;/strong&gt; from the click to every instance changing behaviour. With streaming updates it should be about a second; with polling it is the polling interval.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Put it in the runbook:&lt;/strong&gt; which alert means "flip this switch", who may flip it, and how to tell it worked.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Who can flip a kill switch, and how fast
&lt;/h2&gt;

&lt;p&gt;Production changes deserve review, but an incident cannot wait for one. A good setup separates the two: on-call engineers can flip a switch directly, with a reason that goes into the audit log, while automated changes still wait for a person.&lt;/p&gt;

&lt;p&gt;In Railflag, the flag service I build, you mark the flag as an &lt;strong&gt;ops&lt;/strong&gt; flag so nobody cleans it up as a finished release. A person with edit rights changes Production immediately, with the reason recorded. Changes requested by tokens or AI agents, for example through the MCP server's &lt;code&gt;toggle_flag&lt;/code&gt; tool, wait for a person to approve them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Kill switch vs circuit breaker
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;&lt;/th&gt;
&lt;th&gt;Kill switch&lt;/th&gt;
&lt;th&gt;Circuit breaker&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Triggered by&lt;/td&gt;
&lt;td&gt;A person&lt;/td&gt;
&lt;td&gt;Error rate or latency thresholds&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scope&lt;/td&gt;
&lt;td&gt;Every instance, all at once&lt;/td&gt;
&lt;td&gt;Usually per instance&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Recovers&lt;/td&gt;
&lt;td&gt;When a person turns it back on&lt;/td&gt;
&lt;td&gt;Automatically, after probing&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best for&lt;/td&gt;
&lt;td&gt;Decisions: "stop doing this until we say so"&lt;/td&gt;
&lt;td&gt;Fast automatic protection from flaky dependencies&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;They complement each other. The breaker reacts in milliseconds; the switch makes the decision stick while you investigate.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common mistakes
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Inverted names.&lt;/strong&gt; &lt;code&gt;disable-recommendations = true&lt;/code&gt; means off, and someone will get it backwards under stress. Name switches so that true means running.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Cleaning them up.&lt;/strong&gt; Kill switches look like stale flags because they never change. Mark them as long-lived so cleanup tools leave them alone. (More on that in &lt;a href="https://railflag.com/feature-flag-cleanup?utm_source=devto&amp;amp;utm_medium=social&amp;amp;utm_campaign=kill-switch" rel="noopener noreferrer"&gt;cleaning up feature flags&lt;/a&gt;.)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Remote evaluation on the hot path.&lt;/strong&gt; If every check calls the flag service, the flag service becomes a dependency of every request.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;No owner.&lt;/strong&gt; A switch that nobody remembers is a switch nobody flips in time.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;em&gt;This guide first appeared on &lt;a href="https://railflag.com/kill-switch?utm_source=devto&amp;amp;utm_medium=social&amp;amp;utm_campaign=kill-switch" rel="noopener noreferrer"&gt;railflag.com&lt;/a&gt;. Railflag evaluates flags inside your process, so a kill switch keeps answering when the network doesn't, and a flipped switch reaches every instance within a second. The free plan includes approvals and the audit log: &lt;a href="https://railflag.com/?utm_source=devto&amp;amp;utm_medium=social&amp;amp;utm_campaign=kill-switch" rel="noopener noreferrer"&gt;try it&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>devops</category>
      <category>sre</category>
      <category>webdev</category>
      <category>featureflags</category>
    </item>
  </channel>
</rss>
