<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Notes from the stack</title><link>https://pawful.dev/blog/</link><atom:link href="https://pawful.dev/blog/rss.xml" rel="self" type="application/rss+xml"/><description>Long-form write-ups from Emily Gurnee on infrastructure, backends, and the interfaces on top of them.</description><language>en-us</language><item><title>Moving Darkless into our own rack, behind two Arista switches</title><link>https://pawful.dev/blog/darkless-rack-move/</link><guid>https://pawful.dev/blog/darkless-rack-move/</guid><pubDate>Mon, 16 Nov 2026 12:00:00 GMT</pubDate><description>Darkless now runs behind a pair of Arista 7050SX-64 switches in its own rack. This is how the network is built, what the move broke, and how we change switches we cannot touch.</description><content:encoded><![CDATA[<p>I am a director at <a class="link" href="https://darkless.cloud">Darkless</a>, a hosting company in Charlotte, North Carolina. We sell dedicated servers, VPS, and game hosting on hardware we own, from Ryzen 5 5600X machines up to Ryzen 9 9950X hosts with 256 GB of memory, and we announce our own address space to the internet under our own network number, AS197924.</p>
<p>This year we put all of that behind <strong>two Arista 7050SX-64 switches</strong> that we own, and this month we started moving our servers into <strong>our own rack</strong> behind them.</p>
<p>This is how the network is built, how the move went, and what it broke.</p>
<figure><img src="https://pawful.dev/blog/darkless-rack/rack.avif" alt="Our rack: two Arista 7050SX-64 switches lit up with amber port lights, above a Dell PowerEdge server" width="1200" height="1600" loading="lazy" decoding="async"><figcaption>Our rack. The two Arista switches are at the top, with a hypervisor underneath.</figcaption></figure><h2 id="by-the-numbers">By the numbers<a class="anchor" href="#by-the-numbers" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>2 switches</strong>, running as one pair.</li>
<li><strong>20 Gbps</strong> of uplink to the datacenter&#39;s network.</li>
<li><strong>5 minutes</strong> on the rollback timer for every switch change.</li>
<li><strong>A little over 3 hours</strong> from shutting the servers down to the main hypervisor being back on both switches.</li>
<li><strong>1 day</strong> of credit on every active paid service, because the move ran over.</li>
<li><strong>1 to 2 minutes</strong> of expected downtime if the primary switch dies, once the failover is tested.</li>
</ul>
<h2 id="what-owning-the-switches-gives-us">What owning the switches gives us<a class="anchor" href="#what-owning-the-switches-gives-us" aria-label="Link to this section">#</a></h2>
<p>With our own switches, the first hop inside the rack is hardware we control:</p>
<ul>
<li><strong>Our own BGP session.</strong> We announce our address space ourselves, over a session we configure.</li>
<li><strong>No single cable or switch to lose.</strong> The two switches behave as one, so a server can connect to both.</li>
<li><strong>A management network.</strong> The servers&#39; remote management ports sit on their own network, reachable over our VPN. We can get to a machine&#39;s console when its operating system is down, without asking anyone to walk to the rack.</li>
</ul>
<h2 id="how-the-pair-is-wired">How the pair is wired<a class="anchor" href="#how-the-pair-is-wired" aria-label="Link to this section">#</a></h2>
<p>The two switches run as an MLAG pair. To a server they look like one switch, and it bonds one cable to each of them with LACP. Four links between the switches keep them in step.</p>
<p>The uplink works the same way: the datacenter&#39;s side is one bundle that lands on both of our switches. An older 48-port switch hangs off the pair and handles the 1 Gb management ports.</p>
<h2 id="the-rollout">The rollout<a class="anchor" href="#the-rollout" aria-label="Link to this section">#</a></h2>
<p>The switches went in between <strong>June 22 and July 6</strong>. It was not clean:</p>
<ul>
<li><strong>Downloads were broken at first.</strong> A BGP issue held inbound traffic back until the routing was accepted. The session has been stable since late July.</li>
<li><strong>The internet thought we were in Britain.</strong> Geolocation databases placed our addresses in the UK for a while. They now show Charlotte.</li>
</ul>
<p>Two habits started that month and stuck. On <strong>June 24</strong> we started a git repository that holds each switch&#39;s full configuration, committed after every change. On <strong>July 11</strong> we added a Grafana dashboard for the switches&#39; interfaces.</p>
<h2 id="changing-switches-we-cannot-touch">Changing switches we cannot touch<a class="anchor" href="#changing-switches-we-cannot-touch" aria-label="Link to this section">#</a></h2>
<p>We cannot walk up to the rack. Physical access needs a scheduled visit, so a change that locks us out is a very long outage. Every change to a switch goes through the same five steps:</p>
<ol>
<li>Save a snapshot of the running configuration.</li>
<li>Make the change in a configuration session and read the diff before committing.</li>
<li>Commit with a <strong>five-minute timer</strong>. If nobody confirms in time, the switch undoes the change by itself.</li>
<li>Log in again from a fresh session and check that everything still works. Only then confirm.</li>
<li>Save, and commit the full configuration to git.</li>
</ol>
<p><strong>The rule: a change is not done until you have proved you can still get back in.</strong></p>
<h2 id="moving-day">Moving day<a class="anchor" href="#moving-day" aria-label="Link to this section">#</a></h2>
<p>On <strong>November 15</strong> we shut the servers down at 01:54 UTC and moved them into the new rack.</p>
<p><strong>The first problem was a cable.</strong> After the move, the main hypervisor&#39;s link to the first switch was dead. The switch reported no transceiver in that port. We replaced the cable and added a second one to the other switch, so the hypervisor is now bonded to both. The bond came up at 05:11 UTC.</p>
<p><strong>Then came everything that only starts by hand.</strong> A full power-off is a test of every setting nobody has thought about since the day it was made:</p>
<ul>
<li><strong>Some virtual servers stayed off.</strong> They were set not to start on boot, so they waited until we started them.</li>
<li><strong>Monitoring containers failed to start.</strong> They listen on the VPN address, and Docker started before the VPN had that address. We now let those hosts bind to an address that is not up yet.</li>
<li><strong>The backup server&#39;s clock had no time sources.</strong> Its time service looked up its servers before the network was up, found nothing, and kept nothing. A restart fixed it.</li>
<li><strong>The nightly backup never ran.</strong> Its 02:00 slot fell inside the move, and the catch-up setting did not fire. We ran it by hand.</li>
</ul>
<p>The move ran past its window, so every active paid service got a day of credit.</p>
<p><strong>The lesson: a reboot is a test of everything you configured by hand.</strong></p>
<h2 id="making-routing-survive-a-dead-switch">Making routing survive a dead switch<a class="anchor" href="#making-routing-survive-a-dead-switch" aria-label="Link to this section">#</a></h2>
<p>The cabling is redundant. The routing was not. Our BGP session and our announcement lived on the first switch only. If it died, traffic from the datacenter would still reach the second switch, and nothing there would answer.</p>
<p>That evening we set up a takeover:</p>
<ul>
<li><strong>The second switch carries the same BGP configuration</strong>, with the interface it needs shut down.</li>
<li><strong>A small script watches the link between the switches.</strong> When that link drops, it checks whether the first switch still answers on its separate management port.</li>
<li><strong>If the first switch is silent</strong>, the second one brings the interface up and takes over the session on the same address. Nothing changes on the datacenter&#39;s side.</li>
<li><strong>If the first switch still answers</strong>, the script does nothing. Only the link between them failed, and two switches both claiming the session would be worse than one.</li>
</ul>
<p>When the first switch comes back, the second hands the session back. We expect a real failure to cost one to two minutes, most of it the other side noticing we are gone.</p>
<p>Monitoring changed with it. The alert used to mean &quot;the session on the first switch is down&quot;. It now means &quot;no switch has a session&quot;, with a separate warning when the second switch is the one holding it.</p>
<p>We know what this does not cover. A switch that hangs with its links still up triggers nothing. <strong>And we have not pulled the plug yet.</strong> The configuration, the script, and the monitoring are in place, and the real failover test is waiting for a maintenance window.</p>
<p><strong>Redundant cables are not redundant routing.</strong></p>
<h2 id="what-s-next">What&#39;s next<a class="anchor" href="#what-s-next" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>The failover test,</strong> in a planned maintenance window.</li>
<li><strong>New storage.</strong> Virtual server disks and our primary backups move onto the datacenter&#39;s Ceph storage, over its own network that is never routed. The off-site copy becomes the second level.</li>
<li><strong>The rest of the servers.</strong> A second move was planned for the next day and did not happen. It will get a new window.</li>
</ul>
<p>Thanks to everyone who hosts with Darkless for their patience on moving day. Our <a class="link" href="https://darkless.cloud/status">status page</a> has the next window before it happens.</p>
]]></content:encoded></item><item><title>How we moved Clover off a 128 GB server and onto half a CPU core</title><link>https://pawful.dev/blog/clover-to-azure/</link><guid>https://pawful.dev/blog/clover-to-azure/</guid><pubDate>Mon, 16 Nov 2026 12:00:00 GMT</pubDate><description>We moved Clover's API, Discord bot, and databases from a 128 GB server to Azure. It now costs $41 to $55 a month, and each switch took about three minutes of downtime.</description><content:encoded><![CDATA[<p>I work on <a class="link" href="https://cloverclient.com">Clover</a>, a Minecraft client and launcher. Behind it sit one API, one Discord bot, and a database for each.
Until this month, all of that ran on a dedicated server with <strong>8 cores and 128 GB of RAM</strong>, and used less than <strong>10%</strong> of it.</p>
<p>Over two days, we moved everything to Azure. The two apps now share <strong>half a vCPU and 1 GiB of memory</strong>, next to a small
managed database. The whole thing costs <strong>between $41 and $55 a month</strong>, and each switch took the service down for
<strong>about three minutes</strong>.</p>
<p>This is how it went, including the parts that did not go well.</p>
<h2 id="by-the-numbers">By the numbers<a class="anchor" href="#by-the-numbers" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>2 apps and 2 databases</strong> moved: the API, the Discord bot, and Postgres for both.</li>
<li><strong>59 tables and 2,151 rows.</strong> We are not big. That is the point of this post.</li>
<li><strong>About 3 minutes</strong> offline for each of the two switches.</li>
<li><strong>$41 to $55 a month</strong> for all of it.</li>
<li><strong>2 to 4 minutes</strong> from <code>git push</code> to the new version being live.</li>
<li><strong>17 lines</strong> to fix a websocket bug that turned out to be older than the migration.</li>
</ul>
<figure class="chart">
<div class="bars" style="--max: 20">
<div style="--v: 16.09" title="Database: $16.09 a month"><span>Database</span><i></i><b>$16.09</b></div>
<div style="--v: 14.31" title="API: up to $14.31 a month"><span>API</span><i></i><b>up to $14.31</b></div>
<div style="--v: 5.91; --to: 19.71" title="Discord bot: $5.91 to $19.71 a month"><span>Discord bot</span><i></i><b>$5.91 to $19.71</b></div>
<div style="--v: 5.07" title="Image registry: $5.07 a month"><span>Image registry</span><i></i><b>$5.07</b></div>
</div>
<figcaption>What each piece costs per month: $41 to $55 in total. The lighter part of the bot's bar is the part that depends on how often Azure bills it at the idle rate.</figcaption>
</figure><h2 id="where-we-started">Where we started<a class="anchor" href="#where-we-started" aria-label="Link to this section">#</a></h2>
<p>Clover ran on a small Kubernetes cluster on one very large server, with Caddy and Cloudflare in front, and our own CI runner doing the deploys. It worked. It was also a 128 GB machine doing the job of a Raspberry Pi.</p>
<p>The server is being retired, so we had to move anyway. The obvious answer was a smaller server. We wanted two things
that a smaller server does not give you:</p>
<ul>
<li><strong>No more machines to look after.</strong> Something managed, that can grow later without us rebuilding it.</li>
<li><strong>As cheap as possible</strong> for about 100 players.</li>
</ul>
<h2 id="the-new-setup">The new setup<a class="anchor" href="#the-new-setup" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>Azure Container Apps</strong> runs the API and the bot in one small container each, with a quarter of a vCPU and half a gigabyte of memory.</li>
<li><strong>Azure Database for PostgreSQL</strong> holds both databases on one small server (1 vCore, 2 GiB).</li>
<li><strong>Azure Container Registry</strong> stores the images.</li>
<li><strong>Cloudflare</strong> still sits in front of the API.</li>
<li><strong>Our own CI runner</strong> still builds everything. A deploy is a push to main.</li>
<li><strong>Redis</strong>, which the bot uses for cooldowns and caches, runs as a second container inside the bot&#39;s app.</li>
</ul>
<figure class="chart">
<div class="arch">
<section aria-label="Before"><p><b>Before</b></p>
<ol>
<li>Players</li>
<li>Cloudflare</li>
<li>Caddy</li>
<li class="box"><b>One dedicated server</b><small>8 cores, 128 GB of RAM, under 10% used</small><ul><li>API</li><li>Discord bot</li><li>Postgres for each</li></ul><small>The apps ran in a small Kubernetes cluster</small></li>
</ol>
<p>Deploys: our own CI runner</p></section>
<section aria-label="After"><p><b>After</b></p>
<ol>
<li>Players</li>
<li>Cloudflare</li>
<li class="box"><b>Azure Container Apps</b><small>A quarter of a vCPU and half a gigabyte per app</small><ul><li>API</li><li>Discord bot + Redis</li></ul></li>
<li class="box"><b>Azure Database for PostgreSQL</b><small>1 vCore, 2 GiB, both databases</small></li>
</ol>
<p>Deploys: our own CI runner, pushing images to Azure Container Registry</p></section>
</div>
<figcaption>Clover before and after the move. The bot connects out to Discord directly and stays connected.</figcaption>
</figure><h2 id="what-it-costs-and-why-the-bot-has-a-price-range">What it costs, and why the bot has a price range<a class="anchor" href="#what-it-costs-and-why-the-bot-has-a-price-range" aria-label="Link to this section">#</a></h2>
<p>We did not guess the prices. Azure has a public price list you can query without an account, so we pulled the real
per-second rates for our region and did the arithmetic.</p>
<p>Two things about Container Apps billing took a while to sink in:</p>
<ul>
<li><strong>The free allowance is per subscription, not per app.</strong> One always-on app uses all of it. The second app pays full
price from the first second.</li>
<li><strong>There is an idle rate, and for CPU it is eight times cheaper.</strong> A container is billed as idle only while it handles
no web requests, uses less than 1% of a core, and receives fewer than 1,000 bytes a second.</li>
</ul>
<p>A Discord bot for 100 people is idle most of the day. Whether Azure agrees is something only the first bill can tell
us, which is why the bot is listed at <strong>$5.91 to $19.71</strong>.</p>
<p>We also looked at the alternatives. The same bot on Azure&#39;s plainer container service would be a flat <strong>$9.02</strong>. A
managed Redis starts at <strong>$11.68</strong> a month, which is more than the bot itself might cost. So Redis moved in with the bot.</p>
<h2 id="how-a-deploy-works-now">How a deploy works now<a class="anchor" href="#how-a-deploy-works-now" aria-label="Link to this section">#</a></h2>
<p><strong>One file describes each app.</strong> The image, the secrets, the size, the domain, and its certificate all live in a single
template, and the pipeline applies it on every deploy. The catch is that anything clicked in the Azure portal is undone
by the next push. We found this out halfway through adding the domain by hand.</p>
<p><strong>The config file is a secret.</strong> Both apps read one config file at startup. The whole file is stored as a CI secret,
handed to Azure as a secret, and mounted into the container as a file. One trap: changing a secret does not restart the
app, so the bot gets a fresh copy on every pipeline run to make sure it reads the new one.</p>
<p><strong>The Azure command line never gets installed.</strong> Installing it on our runner failed, because the installer tries to
replace a certificate file the runner has mounted from its host. The job now borrows Microsoft&#39;s own container image
for that one step.</p>
<h2 id="moving-the-data-without-losing-a-row">Moving the data without losing a row<a class="anchor" href="#moving-the-data-without-losing-a-row" aria-label="Link to this section">#</a></h2>
<p>We had two rules.</p>
<p><strong>Rehearse with production still running.</strong> The first copy of each database happened while everything was live. Nothing
was interrupted, and we learned how long the real one would take.</p>
<p><strong>Count every table on both sides.</strong> After each copy we compared row counts table by table. Not a total. Every table.</p>
<p>Then we did the real thing, twice: stop the old app, copy the database (<strong>29 seconds</strong> for the API, <strong>4 seconds</strong> for the bot), start the new app on the copied data, and point the traffic at it.</p>
<p>The API was answering again <strong>3 minutes and 6 seconds</strong> after we stopped it. The bot took <strong>3 minutes and 4 seconds</strong>.</p>
<p>The one surprise was that the managed database refuses Postgres extensions until you allow each one in a server
setting. Our very first migration needs one.</p>
<h2 id="a-discord-bot-on-a-platform-built-for-websites">A Discord bot on a platform built for websites<a class="anchor" href="#a-discord-bot-on-a-platform-built-for-websites" aria-label="Link to this section">#</a></h2>
<p>Container Apps is designed around things that answer web requests. A bot answers nothing. It dials out to Discord and
stays connected. That mostly works, with three quirks.</p>
<ul>
<li><strong>Redis rides along.</strong> A second container in the same app shares the bot&#39;s network, so the bot talks to Redis on
localhost. Both containers have to fit inside one of the allowed sizes, so we measured first: the bot peaked at
<strong>182 MiB</strong>.</li>
<li><strong>It forgets on every deploy.</strong> The Redis container has no disk and starts empty each time. That is fine for cooldowns, but not for anything you want to keep.</li>
<li><strong>Zero-downtime deploys are wrong for a bot.</strong> Azure starts the new copy before stopping the old one. For a website, that is the whole idea. For a bot, it means two bots are online for a moment, both answering.</li>
</ul>
<h2 id="two-things-we-found-on-the-way">Two things we found on the way<a class="anchor" href="#two-things-we-found-on-the-way" aria-label="Link to this section">#</a></h2>
<p><strong>The move fixed a bug we did not know we had.</strong> Requests now pass through Cloudflare and Azure before reaching our
code, so we had to tell the API which proxies to trust. While checking that, we found the old setup had been saving
Cloudflare&#39;s address instead of the player&#39;s for the <strong>68 most recent sessions</strong>.</p>
<p><strong>&quot;It can autoscale&quot; is not the same as &quot;we can autoscale.&quot;</strong> We wanted autoscaling. Then we read our own code. The API
keeps its live connections and its rate limits in memory, so two copies would each see half the players. It runs as
exactly one copy until that changes. The platform was ready before we were.</p>
<h2 id="what-broke">What broke<a class="anchor" href="#what-broke" aria-label="Link to this section">#</a></h2>
<p><strong>The first region said no.</strong> The cheapest database size was refused in the first region we picked, and again in the
second, after other pieces had already been built there. Start with the piece most likely to refuse.</p>
<p><strong>Then the bot kept hanging up.</strong> After the move, we noticed the bot&#39;s connection to the API dropping and reconnecting
every two minutes. The natural assumption was that the migration had broken it.</p>
<p>So we measured the gaps: <strong>125, 125, 126 seconds</strong>. Then we counted: <strong>460 reconnects in about 17 hours</strong>.</p>
<p>The cause was older than the migration. That connection carries nothing unless a player comes online, and Cloudflare
closes websockets that stay silent. Player connections got a ping every 30 seconds. The bot&#39;s connection got none. The
fix was 17 lines, and the old server sat behind Cloudflare too, so this had very likely been going on long before we
moved.</p>
<p><strong>The lesson: a number that steady is a timeout, not a crash.</strong></p>
<figure class="chart">
<div class="timeline" style="--span: 780">
<div><span>Before the fix</span><p><i style="--at: 0; --len: 125.5"></i><i style="--at: 125.5; --len: 125.5"></i><i style="--at: 251; --len: 125.5"></i><i style="--at: 376.5; --len: 125.5"></i><i style="--at: 502; --len: 125.5"></i><i style="--at: 627.5; --len: 125.5"></i></p><small>Six connections in a row, each dropped after 125 or 126 seconds</small></div>
<div><span>After the fix</span><p><i class="open" style="--len: 600"></i></p><small>Still connected nine minutes later, when we stopped watching</small></div>
<div class="axis"><span></span><p><b style="--at: 0">0</b><b style="--at: 180">3 min</b><b style="--at: 360">6 min</b><b style="--at: 540">9 min</b><b style="--at: 720">12 min</b></p></div>
</div>
<figcaption>How long the bot's connection to the API lasted, before and after the 17-line fix.</figcaption>
</figure><p><strong>And our own check lied to us.</strong> For a few minutes, we believed the bot was down, while it was happily answering
commands. Our &quot;is it talking to the database&quot; check ran inside one transaction, and Postgres shows a transaction a
frozen picture of who is connected. We were polling a photograph.</p>
<h2 id="what-we-gave-up">What we gave up<a class="anchor" href="#what-we-gave-up" aria-label="Link to this section">#</a></h2>
<p>Moving the apps turned out not to be the whole job.</p>
<ul>
<li><strong>Metrics.</strong> Our dashboards read from both apps directly. On Azure, there is nothing for them to reach, so they have
nothing new to show.</li>
<li><strong>Backups.</strong> The nightly dumps kept running, against the old database that no longer changes. The live data had only
Azure&#39;s built-in seven days.</li>
<li><strong>Logs.</strong> They are in Azure now, not next to everything else we run.</li>
</ul>
<p>None of it is hard to fix. All of it was invisible until after the switch.</p>
<p><strong>A migration is not finished when the app answers. It is finished when the monitoring and the backups have moved too.</strong></p>
<h2 id="what-s-next">What&#39;s next<a class="anchor" href="#what-s-next" aria-label="Link to this section">#</a></h2>
<ul>
<li><strong>Shared state for the API,</strong> so it can run more than one copy and the autoscaling we came for can be switched on.</li>
<li><strong>Metrics and dashboards</strong> for the two apps in their new home.</li>
<li><strong>Off-site database dumps</strong> again.</li>
<li><strong>A working uptime ping for the bot.</strong> The old one points at a service we replaced.</li>
<li><strong>Turning the big server off.</strong></li>
</ul>
<p>Thanks to everyone who plays Clover and hangs out in the Discord, including during the three minutes the bot went missing. If something feels off since the move, tell us there.</p>
]]></content:encoded></item></channel></rss>