<?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: Sergey Shinder</title>
    <description>The latest articles on DEV Community by Sergey Shinder (@sergey_shinder_ab2d943365).</description>
    <link>https://dev.to/sergey_shinder_ab2d943365</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%2F4106609%2F9b5134a1-5dd9-4622-8a18-fd48f8ea8b5c.png</url>
      <title>DEV Community: Sergey Shinder</title>
      <link>https://dev.to/sergey_shinder_ab2d943365</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sergey_shinder_ab2d943365"/>
    <language>en</language>
    <item>
      <title>Our label workers scaled in on an empty queue and stopped the one instance still building the evening manifest</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Wed, 25 Nov 2026 11:18:02 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/our-label-workers-scaled-in-on-an-empty-queue-and-stopped-the-one-instance-still-building-the-5d50</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/our-label-workers-scaled-in-on-an-empty-queue-and-stopped-the-one-instance-still-building-the-5d50</guid>
      <description>&lt;p&gt;Every evening our label workers build the manifest for our largest carrier: one file listing every parcel collected that day, which has to reach the carrier before half past six or the collection is not booked. The workers are EC2 instances in an auto scaling group, consuming jobs from a RabbitMQ queue. A small exporter publishes the queue depth to CloudWatch, and a target tracking policy keeps roughly one instance per twenty waiting jobs, with a minimum of one.&lt;/p&gt;

&lt;p&gt;The manifest job is the last one of the day and takes about forty minutes. On a Tuesday in November it was picked up at ten to six by one of four running instances. A few minutes later the policy scaled the group in to one, and the instance it chose to remove was the one building the manifest.&lt;/p&gt;

&lt;p&gt;The exporter published messages ready, the count of jobs nobody had taken yet. A job a worker is processing is unacknowledged, and does not count as ready. Once the manifest was taken, the queue looked empty, the metric said zero, and the policy did exactly what it was told. The auto scaling group chooses which instance to terminate by its own termination policy, balancing availability zones first. Nothing in it knows which instance is busy.&lt;/p&gt;

&lt;p&gt;When the instance shut down, its connection to RabbitMQ closed and the broker returned the unacknowledged job to the queue, as it should. The remaining worker started the manifest from the beginning at four minutes past six. It finished at thirteen minutes to seven, and the carrier booked our collection for the next morning.&lt;/p&gt;

&lt;p&gt;Three changes followed. A worker now sets scale in protection on its own instance when it takes a job and removes it after acknowledging the job, so the group will not choose a busy instance when it scales in. The scaling metric is now ready plus unacknowledged messages, the work that exists rather than the work waiting. The manifest job writes a checkpoint every five hundred parcels, so a restart continues from the last one. A lifecycle hook also gives a worker that is being terminated time to finish or checkpoint its current job before it stops.&lt;/p&gt;

&lt;p&gt;An autoscaler can only see the number it is given. Ours was given the queue, and the most important work of the day was not in it.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>aws</category>
      <category>rabbitmq</category>
      <category>sre</category>
    </item>
    <item>
      <title>We reverted a feature on the release branch and merging the release back into main removed it there too</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Wed, 25 Nov 2026 11:12:51 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/we-reverted-a-feature-on-the-release-branch-and-merging-the-release-back-into-main-removed-it-there-pln</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/we-reverted-a-feature-on-the-release-branch-and-merging-the-release-back-into-main-removed-it-there-pln</guid>
      <description>&lt;p&gt;Our integration platform ships to customers as versioned releases. Two weeks before each release we cut a branch from main, release/5.7 this time, and only fixes go onto it. When the release is out, we merge the release branch back into main so every fix made on it reaches the next version.&lt;/p&gt;

&lt;p&gt;During testing of 5.7 we found that a new carrier routing feature mislabelled international parcels in one case. It was too late to fix safely, so the release manager reverted its merge commit on the release branch with git revert -m 1, and 5.7 shipped without it. The feature's team kept working on the fix on main.&lt;/p&gt;

&lt;p&gt;After the release, we merged release/5.7 back into main as usual. Two days later the team merged their fix, and their tests failed with errors from classes that no longer existed. The feature had disappeared from main.&lt;/p&gt;

&lt;p&gt;A revert is not a note saying leave this out of the release. It is an ordinary commit that deletes the changes, and Git merges it like any other. Main had not touched those lines since the branch was cut, so the merge applied the deletion cleanly, without a conflict, and the review of the merge back showed several thousand lines of diff that everybody expected to be large.&lt;/p&gt;

&lt;p&gt;The obvious repair does not work either. The feature's original commits are already in main's history, so merging their branch again changes nothing, and Git reports it as up to date. As far as Git is concerned the feature was added and then deliberately removed. To bring it back, you revert the revert: git revert on the commit that the merge brought into main. That is what we did, and the team's fix went in on top of it the same afternoon.&lt;/p&gt;

&lt;p&gt;The process changed in two places. A revert on a release branch is now done on a short branch with a name starting revert/, and the merge back into main is a pipeline step that lists every such revert it is about to bring in and stops until somebody decides for each one. Usually the answer is to revert it again on main straight after the merge.&lt;/p&gt;

&lt;p&gt;Git records what was done to the code, not why. A revert made for one branch's reasons travels with every merge from that branch.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>git</category>
      <category>releases</category>
      <category>devops</category>
    </item>
    <item>
      <title>We minified our despatch email template and the mail relay started putting spaces in the middle of tracking links</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Wed, 25 Nov 2026 11:07:41 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/we-minified-our-despatch-email-template-and-the-mail-relay-started-putting-spaces-in-the-middle-of-4pni</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/we-minified-our-despatch-email-template-and-the-mail-relay-started-putting-spaces-in-the-middle-of-4pni</guid>
      <description>&lt;p&gt;When a parcel leaves one of our depots, our notification service emails the customer a despatch confirmation with the carrier's tracking link. The service is old. It builds the raw message from a template file that holds the headers and an HTML body, and one of those headers, written in 2016, says Content-Transfer-Encoding: 8bit. The messages go out through the Postfix 3.7 relay that Debian 12 ships, on one of our servers.&lt;/p&gt;

&lt;p&gt;In October a front end colleague tidied our email templates and added a build step that minified the HTML, to make the messages smaller. The despatch email's body became one line of about eleven thousand characters.&lt;/p&gt;

&lt;p&gt;Within a week customer service had a pattern. Some customers clicked the tracking link and got the carrier's page saying the parcel did not exist. A few had screenshots of order numbers with a space in the middle.&lt;/p&gt;

&lt;p&gt;The mail standard limits a line to 998 characters, not counting the line ending. Postfix enforces that when it sends a message on. Its smtp_line_length_limit is 998 by default, and a longer line is broken by inserting a line ending followed by a space, which keeps the message valid and changes its content. Our single line was cut every 998 characters, wherever that fell. When it fell inside an href, the browser kept the space, encoded it as %20, and the carrier rejected the reference. When it fell inside text, the order number on screen had a gap. Which customers were affected depended on the length of their name, address and items, because those moved every break point.&lt;/p&gt;

&lt;p&gt;Before the minification, the template's HTML had short lines and the limit never came near it. The header saying 8bit had been a promise the message no longer kept, and nothing between our code and the relay checked it.&lt;/p&gt;

&lt;p&gt;The template now declares Content-Transfer-Encoding: quoted-printable, and the service encodes the body that way. Quoted-printable keeps lines under seventy six characters with soft breaks that the receiving mail client removes, so the HTML arrives exactly as written, however long its lines are. A test builds a despatch email for an order with a very long address and fails if any line in the raw message is longer than 998 characters. We kept the minification.&lt;/p&gt;

&lt;p&gt;A message passes through systems that are allowed to rewrite whatever breaks the rules. If you declare an encoding, make the content keep the promise, or the next system will keep it for you, in its own way.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>email</category>
      <category>integration</category>
      <category>linux</category>
    </item>
    <item>
      <title>Last year's Black Friday looked like fifty eight percent CPU because CloudWatch only had hourly averages of it left</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Wed, 25 Nov 2026 11:02:30 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/last-years-black-friday-looked-like-fifty-eight-percent-cpu-because-cloudwatch-only-had-hourly-561e</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/last-years-black-friday-looked-like-fifty-eight-percent-cpu-because-cloudwatch-only-had-hourly-561e</guid>
      <description>&lt;p&gt;In October we reviewed the size of the database behind our order system ahead of the peak season. The proposal was to move it down one instance size, and the evidence was a CloudWatch graph of CPUUtilization for last November. The busiest hour of Black Friday 2025 had peaked at fifty eight percent.&lt;/p&gt;

&lt;p&gt;One of our database engineers asked to see the same hour with the Maximum statistic instead of Average. It said ninety nine.&lt;/p&gt;

&lt;p&gt;CloudWatch keeps metric data at full resolution only for a while. Data published every minute stays available at one minute resolution for fifteen days. After that it is aggregated to five minute points, kept for sixty three days, and after sixty three days to one hour points, kept for four hundred and fifty five days. Last November was about eleven months old, so all that was left of the day was one point per hour.&lt;/p&gt;

&lt;p&gt;Each of those points still carries the minimum, maximum, sum and sample count of the minutes inside it. The graph shows Average unless you ask for something else, and the average of an hour in which the database spent eighteen minutes saturated and the rest at forty or fifty percent is a comfortable fifty eight. Our incident log for that day had a ticket for slow checkout between twenty to twelve and two minutes to twelve. The graph had folded those eighteen minutes into an hour.&lt;/p&gt;

&lt;p&gt;We kept the current size and had a long talk about how close we had come.&lt;/p&gt;

&lt;p&gt;Three things changed. When a peak day ends, a scheduled job exports its metrics at one minute resolution from CloudWatch to S3 while they still exist, for the database, the load balancers and the queues, and a small notebook can redraw any of them later at full detail. Our capacity panels show Maximum and a high percentile next to Average, and any panel showing a period older than fifteen days says in its title what resolution it is drawing. Capacity proposals now have to state the resolution of the data they cite.&lt;/p&gt;

&lt;p&gt;The proposal was not careless. Average is the default, the graph was real, and the number on it was accurate for the hour it described.&lt;/p&gt;

&lt;p&gt;Resolution is part of a measurement. A peak that lasts minutes cannot be found in data that only remembers hours, and in CloudWatch the minutes expire on a schedule whether or not anybody has looked at them yet.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>aws</category>
      <category>monitoring</category>
      <category>performance</category>
    </item>
    <item>
      <title>Our Java pod was killed for memory with a third of its heap free because glibc gave it an arena for every core on the node</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Wed, 25 Nov 2026 10:57:20 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/our-java-pod-was-killed-for-memory-with-a-third-of-its-heap-free-because-glibc-gave-it-an-arena-for-4k3c</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/our-java-pod-was-killed-for-memory-with-a-third-of-its-heap-free-because-glibc-gave-it-an-arena-for-4k3c</guid>
      <description>&lt;p&gt;Our label rendering service is a Java application that builds carrier labels as PDFs. On virtual machines it ran for months without a restart. In September we moved it to Kubernetes with a memory limit of three gigabytes and a heap of one and a half, and from then on each pod was OOMKilled every four or five days.&lt;/p&gt;

&lt;p&gt;The heap was not the problem. Our JVM graphs showed it peaking at about a gigabyte after collection. Native Memory Tracking, which reports what the JVM itself has allocated outside the heap, came to about two gigabytes in total and stayed flat. The container's resident memory kept climbing past that by around a hundred megabytes a day until the kernel killed it.&lt;/p&gt;

&lt;p&gt;pmap -x on a running pod showed the gap: dozens of anonymous mappings of almost exactly sixty four megabytes each. That shape belongs to glibc's malloc, not to Java. To keep threads from queueing on one lock, glibc gives allocating threads separate arenas, each with its own heaps of up to sixty four megabytes, and on a 64 bit system it allows up to eight arenas per CPU core. It counts the cores the machine has, not the CPU limit of the container. Our old virtual machines had eight cores. Our Kubernetes nodes have forty eight, so the same process was allowed three hundred and eighty four arenas.&lt;/p&gt;

&lt;p&gt;The service allocates native memory from many threads: the PDF library inflating fonts and images through java.util.zip, and the network library's own buffers. Memory freed inside an arena is often kept for reuse rather than returned to the system, so with hundreds of arenas, each holding scraps nobody would use again, resident memory only grew. Native Memory Tracking could not see it, because it counts what the JVM asked malloc for, not what malloc keeps afterwards.&lt;/p&gt;

&lt;p&gt;The fix was one environment variable in the Deployment, MALLOC_ARENA_MAX=2. Resident memory now levels off at about 2.1 gigabytes within a day and stays there. Fewer arenas means more threads contending for each one, so we compared render latency for a week before and after, and could not find a difference at our load.&lt;/p&gt;

&lt;p&gt;Our base image now sets the variable for every Java service, and the memory dashboard shows resident memory next to the JVM's own total, so a gap between them is visible the week it opens, not on the fifth restart.&lt;/p&gt;

&lt;p&gt;A container limits what a process may use. It does not change what the process believes about the machine.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>kubernetes</category>
      <category>java</category>
      <category>linux</category>
    </item>
    <item>
      <title>Ansible bound our scanner API to the wrong network card on the new depot gateways because the default route used the other one</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Wed, 25 Nov 2026 10:52:09 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/ansible-bound-our-scanner-api-to-the-wrong-network-card-on-the-new-depot-gateways-because-the-36kk</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/ansible-bound-our-scanner-api-to-the-wrong-network-card-on-the-new-depot-gateways-because-the-36kk</guid>
      <description>&lt;p&gt;Each of our depots has a small Debian gateway that the handheld scanners talk to. Our playbook templates the scanner API's configuration, and one line in it has been the same for four years: bind_address: {{ ansible_default_ipv4.address }}. Every gateway had one network card on the depot LAN, so the default IPv4 address and the LAN address were the same thing.&lt;/p&gt;

&lt;p&gt;In November we opened two new depots with a new gateway build. These have two network cards. enp1s0 is on the depot LAN. enp2s0 is a dedicated internet line for carrier traffic, and the default route goes out through it, because that is where everything outside the depot needs to go. The playbook ran green on both, our post deploy smoke test passed, and on the first morning not one scanner could connect.&lt;/p&gt;

&lt;p&gt;ansible_default_ipv4 is not the main address of the machine, whatever the name suggests. Ansible fills it in by asking the kernel which route it would take to reach a public address, 8.8.8.8, and reporting the interface and address of that route. On the new gateways that was enp2s0, so the scanner API listened on the address of the internet line. The host firewall drops anything arriving on that interface except replies, so the service was unreachable from the outside, and it was unreachable from the LAN as well, because nothing was listening on the LAN address.&lt;/p&gt;

&lt;p&gt;The smoke test ran on the gateway itself and called the API on the configured address. From inside the machine, the internet line's address is as local as any other, so the test connected every time.&lt;/p&gt;

&lt;p&gt;The depots scanned on paper for two hours while we edited the file by hand on both gateways.&lt;/p&gt;

&lt;p&gt;The template no longer reads a fact chosen by routing. Each gateway in the inventory declares its LAN interface, the template takes that interface's address from the facts, and an assert task fails the play if the address is not inside the depot LAN range that the inventory also holds. The smoke test now runs from the playbook's control node through the depot's LAN address, the way a scanner would reach it, and a gateway with two cards gets the same test as one with a single card.&lt;/p&gt;

&lt;p&gt;A fact is answered by the question Ansible asked to get it. Ours was where traffic leaves the machine, and we had been reading it as where traffic arrives.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>ansible</category>
      <category>linux</category>
      <category>networking</category>
    </item>
    <item>
      <title>Our drift report pointed the deploy runner's kubectl at production and the next staging deploy followed it</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Wed, 25 Nov 2026 10:46:59 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/our-drift-report-pointed-the-deploy-runners-kubectl-at-production-and-the-next-staging-deploy-3jkj</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/our-drift-report-pointed-the-deploy-runners-kubectl-at-production-and-the-next-staging-deploy-3jkj</guid>
      <description>&lt;p&gt;Our deploys to Kubernetes run on a self hosted runner, a long lived virtual machine inside our network with an IAM role that can reach both of our EKS clusters, staging and production. The production job has always named its cluster explicitly. The staging job never did. It ran kubectl apply -k overlays/staging and relied on the current context in the runner's kubeconfig, which had pointed at staging since the day the machine was built.&lt;/p&gt;

&lt;p&gt;In September a colleague added a nightly drift report to the same runner. It ran aws eks update-kubeconfig --name prod-eu, then kubectl diff against the production manifests, and posted the result in our channel. It was a read only job and it was reviewed as one.&lt;/p&gt;

&lt;p&gt;At twelve minutes past nine the next morning a developer merged a change to the label service and the staging deploy ran. Twenty six minutes later our Wakefield depot rang to say every label coming off the printers was a carrier test label that their scanners refused.&lt;/p&gt;

&lt;p&gt;update-kubeconfig does two things. It writes the cluster into ~/.kube/config, and it makes that cluster the current context. The file lives in the home directory of the runner's user, so it is not cleaned up between jobs the way the workspace is. The drift report had left the runner pointed at production, and the staging deploy applied the staging overlay there. Both clusters use the same namespace names, so nothing failed. Production's label service restarted with staging's configuration, carrier sandbox endpoints included, and printed sandbox labels until we redeployed the production overlay.&lt;/p&gt;

&lt;p&gt;Nothing in the staging job was wrong on the day it was written. It depended on a piece of state outside the job, and another job was free to change it.&lt;/p&gt;

&lt;p&gt;Every job now sets KUBECONFIG to a file in RUNNER_TEMP, which the runner empties at the start and end of each job, and writes its own cluster into it. Every kubectl call passes --context. Before applying anything, the deploy step compares the cluster ARN in its context with the one the environment expects and stops if they differ. Production deploys moved to a separate runner whose role cannot see staging, and staging's role cannot see production. The runners are now ephemeral: each one takes a single job and is replaced.&lt;/p&gt;

&lt;p&gt;A job should carry everything it relies on. Anything it finds lying around was left there by somebody else's job.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>kubernetes</category>
      <category>cicd</category>
      <category>devops</category>
    </item>
    <item>
      <title>We ran our despatch scheduler as a StatefulSet so it could never run twice, and that kept it stopped for two hours</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Wed, 25 Nov 2026 07:34:33 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/we-ran-our-despatch-scheduler-as-a-statefulset-so-it-could-never-run-twice-and-that-kept-it-1fdj</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/we-ran-our-despatch-scheduler-as-a-statefulset-so-it-could-never-run-twice-and-that-kept-it-1fdj</guid>
      <description>&lt;p&gt;Our despatch scheduler batches orders into carrier collections, and it must never run as two copies at once, or the same orders go into two collections. So it runs in Kubernetes as a StatefulSet with one replica. A Deployment's rolling update starts a new pod before the old one has gone. A StatefulSet promises at most one pod with a given name, which was exactly the guarantee we wanted.&lt;/p&gt;

&lt;p&gt;On a Tuesday in October, at ten past two, the virtual machine under that pod hung. The kernel stopped responding, but the hypervisor still reported the machine as running, so it stayed in the cluster. Within a minute the node was NotReady. Five minutes later Kubernetes marked the scheduler's pod for deletion, as it does by default for pods on an unreachable node. Then nothing happened for the next hour and fifty minutes. Two afternoon collections left without the orders meant for them.&lt;/p&gt;

&lt;p&gt;A pod on an unreachable node cannot be confirmed dead, because the only thing that could confirm it is the kubelet on that node. So the pod sat in Terminating. A ReplicaSet would have started a replacement elsewhere straight away, since it does not count terminating pods. A StatefulSet will not create despatch-scheduler-0 again until the old despatch-scheduler-0 is gone from the API server, because the old one might still be running on a machine nobody can see. The guarantee we chose the StatefulSet for was working perfectly. It had no way to tell a hung machine from a busy one.&lt;/p&gt;

&lt;p&gt;At four o'clock an engineer found the pod in Terminating, deleted it with --force, and the scheduler started on another node within a minute.&lt;/p&gt;

&lt;p&gt;Force deletion is only safe if the old copy really is stopped, so our runbook now begins with fencing: power the virtual machine off through the cloud API and confirm it is off. Then we apply the node.kubernetes.io/out-of-service taint, stable since Kubernetes 1.28, which deletes the pods on that node and detaches its volumes without waiting for a kubelet that is never coming back. We have alerts on any pod in Terminating for more than ten minutes, and on any StatefulSet with fewer ready replicas than desired.&lt;/p&gt;

&lt;p&gt;At most one, done safely, sometimes means none, and somebody has to be told when it does.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>kubernetes</category>
      <category>sre</category>
      <category>reliability</category>
    </item>
    <item>
      <title>We added one field to the object in our sessions and rolling back made the errors worse</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Tue, 24 Nov 2026 07:37:51 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/we-added-one-field-to-the-object-in-our-sessions-and-rolling-back-made-the-errors-worse-1fke</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/we-added-one-field-to-the-object-in-our-sessions-and-rolling-back-made-the-errors-worse-1fke</guid>
      <description>&lt;p&gt;Our trade portal is a Spring Boot application on eight pods, with sessions stored in Redis through Spring Session so a customer can land on any pod. A release in October added one field to the customer context object we keep in the session: the depot a customer prefers to collect from. The rollout started at ten past eleven, one pod at a time.&lt;/p&gt;

&lt;p&gt;Within two minutes customers with an open session started getting error pages, on some clicks and not on others. The logs had java.io.InvalidClassException: local class incompatible, stream classdesc serialVersionUID differs from the local class.&lt;/p&gt;

&lt;p&gt;Spring Session's default serializer for Redis is plain Java serialization. A Serializable class with no explicit serialVersionUID gets one computed from its structure, so adding a field gives it a different value, and Java refuses to read a stream written with another. During the rollout, whichever version wrote a session last, the other version could not read it. Each customer's next click was a coin toss between an old pod and a new one.&lt;/p&gt;

&lt;p&gt;We rolled back. It made things worse. By then the new pods had rewritten thousands of sessions, the old version could not read any of them, and now every pod was old. Neither version could read what the other had written, and backwards was no safer than forwards.&lt;/p&gt;

&lt;p&gt;The fix that afternoon used serialver, a tool in the JDK that prints the serialVersionUID a class would get. We ran it against the class in the previous release, pinned that value in the new class and released again. Java serialization treats an added field as a compatible change when the identifiers match, and the new field simply arrived empty from old sessions. The errors stopped as the release completed.&lt;/p&gt;

&lt;p&gt;Since then every serializable class in the portal declares its serialVersionUID, and a build check fails on one that does not. Sessions are now serialized as JSON, through a bean named springSessionDefaultRedisSerializer, with unknown fields ignored. We switched serializers early on a Sunday morning and accepted that everyone had to sign in again once. The release pipeline has a test that writes a session with the previous release and reads it with the new one, and the other way round.&lt;/p&gt;

&lt;p&gt;Any data shared between two versions of an application is an interface between them, whether or not anybody designed it as one.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>java</category>
      <category>spring</category>
      <category>deployment</category>
    </item>
    <item>
      <title>Our carrier's new tracking webhooks sent seconds and every scan that week happened in January 1970</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Tue, 24 Nov 2026 07:32:41 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/our-carriers-new-tracking-webhooks-sent-seconds-and-every-scan-that-week-happened-in-january-1970-2iip</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/our-carriers-new-tracking-webhooks-sent-seconds-and-every-scan-that-week-happened-in-january-1970-2iip</guid>
      <description>&lt;p&gt;One of our parcel carriers sends tracking events to a webhook: collected, at the hub, out for delivery, delivered. A Node.js service receives them, stores the raw payload, and works out each parcel's current status as the event with the latest timestamp. Customer service and our tracking page both read that status.&lt;/p&gt;

&lt;p&gt;In October the carrier moved its webhooks to version three. We had tested the new payload shape in their sandbox and switched on a Tuesday. Two days later customer service asked why two thousand three hundred parcels had been out for delivery since Monday, and whether we should start lost parcel claims.&lt;/p&gt;

&lt;p&gt;The changelog for version three had one line about time: event timestamps are now Unix seconds. Version two had sent milliseconds. Our code passed the number straight to new Date(), which in JavaScript always means milliseconds since 1970. A scan at 14:00 on 14 October 2026, about 1,791,986,000 seconds, became a moment on 21 January 1970.&lt;/p&gt;

&lt;p&gt;Nothing failed. Every event was valid, stored and dated. For parcels booked after the switch every event was in 1970, still in the right order, so their status looked correct. The damage was to parcels already on the road when we switched. Their older events from version two had real dates in 2026, so every new event, including delivered, was fifty six years older than the last one we already had, and never became the latest. Those parcels stopped moving at whatever their status had been on Monday morning.&lt;/p&gt;

&lt;p&gt;The service now converts timestamps by the version of the payload, written out in one function with a test for each version. Every event goes through a sanity check before it can change a status: it must not be earlier than the shipment was booked or more than an hour in the future. An event that fails goes to a quarantine table with the reason, and an alert fires on the first one. Because we keep raw payloads, we replayed the two days of events through the fixed code and every parcel caught up within the hour. The contract tests against the carrier's sandbox now compare the event time with the time the scan was triggered, not only the shape of the JSON.&lt;/p&gt;

&lt;p&gt;The carrier told us, in a changelog we had read. We had checked that each field was there, and not what its numbers meant.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>javascript</category>
      <category>api</category>
      <category>integration</category>
    </item>
    <item>
      <title>Our label adapter got seven times slower and our CPU graph stayed at forty percent because the time was being stolen</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Tue, 24 Nov 2026 07:27:30 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/our-label-adapter-got-seven-times-slower-and-our-cpu-graph-stayed-at-forty-percent-because-the-time-1iej</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/our-label-adapter-got-seven-times-slower-and-our-cpu-graph-stayed-at-forty-percent-because-the-time-1iej</guid>
      <description>&lt;p&gt;Our carrier label adapters run on eight virtual machines at a hosting provider, a Java service on each. In October the adapter's p95 latency went from about a hundred and twenty milliseconds to nine hundred during business hours, every day, and settled again in the evening.&lt;/p&gt;

&lt;p&gt;The CPU panel on our dashboard said the machines were bored. It showed forty percent, the same as it had shown all year. So we looked everywhere else. We profiled the JVM, tuned the garbage collector and opened a ticket with the carrier. Two days went that way.&lt;/p&gt;

&lt;p&gt;On the third morning a colleague ran top on one of the gateways and read the CPU line out loud. User and system together were about forty percent. The last figure on that line, st, was thirty eight.&lt;/p&gt;

&lt;p&gt;st is steal time. On a virtual machine, a virtual CPU can be ready to run while the hypervisor is busy running something else, usually another customer's machine on the same physical host. The guest kernel cannot use that time, and it is not idle either, so Linux counts it separately, in the steal column of /proc/stat. node_exporter exports it as its own mode of node_cpu_seconds_total, mode="steal". Our panel added up only user and system. Somebody had built it that way years earlier to keep iowait out of the picture, and steal went out with it. Our service was not using more CPU, because while it waited for a turn it was not running at all. Its requests simply waited where no metric of ours could see them.&lt;/p&gt;

&lt;p&gt;The provider confirmed that our machines had been moved to a busier host during maintenance at the start of the month. They moved us back, and the next morning steal was under two percent and the p95 was back to a hundred and twenty.&lt;/p&gt;

&lt;p&gt;The CPU panel now stacks every mode the kernel reports, user, system, iowait, steal and idle, so they add up to the whole and nothing can leave the picture without being noticed. An alert fires when steal stays above ten percent for fifteen minutes on any machine. The gateways have since moved to the provider's dedicated CPU plan, and the alert is there to tell us if it ever does not.&lt;/p&gt;

&lt;p&gt;The graph showed exactly the time our service had used. The problem was in the time it had been waiting for.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>linux</category>
      <category>monitoring</category>
      <category>performance</category>
    </item>
    <item>
      <title>We moved our label reference generator into Kubernetes and pods on different nodes started issuing the same numbers</title>
      <dc:creator>Sergey Shinder</dc:creator>
      <pubDate>Tue, 24 Nov 2026 07:22:20 +0000</pubDate>
      <link>https://dev.to/sergey_shinder_ab2d943365/we-moved-our-label-reference-generator-into-kubernetes-and-pods-on-different-nodes-started-issuing-308</link>
      <guid>https://dev.to/sergey_shinder_ab2d943365/we-moved-our-label-reference-generator-into-kubernetes-and-pods-on-different-nodes-started-issuing-308</guid>
      <description>&lt;p&gt;Every parcel we send gets a reference that goes on the carrier's label and comes back to us on every tracking event. A small Java service hands them out. Each reference is a millisecond timestamp, a worker number and a counter that starts at zero every millisecond. For six years the service ran on four virtual machines in one subnet with 256 addresses, and the worker number was the last byte of the machine's IP address. Inside one subnet of that size, no two machines can share a last byte, so it was unique by construction, and nothing else checked.&lt;/p&gt;

&lt;p&gt;In September we moved the service into Kubernetes and let it scale with load. Three weeks later a customer rang to ask why she had been told her parcel was delivered to an address in another town.&lt;/p&gt;

&lt;p&gt;Our cluster gives each node its own block of 256 addresses for its pods, a common default. Pod addresses are unique across the cluster, but their last bytes are not. A pod at 10.244.3.21 and a pod at 10.244.7.21 got the same worker number. When both issued their first reference in the same millisecond, both counters were zero, and the two references were identical. At quiet times it almost never happened. At peak, with nine pods, it happened a few times a day.&lt;/p&gt;

&lt;p&gt;The shipments table had no unique constraint on the reference, because the generator could not produce duplicates. Tracking events from the carrier were matched by reference, so each pair of parcels shared one stream of scans, and one customer received the other's delivery notice. We found thirty seven pairs.&lt;/p&gt;

&lt;p&gt;A worker number is now leased, not derived. At startup each pod claims a free number from a table in Postgres, writes its pod name and an expiry two minutes ahead, and renews the lease every thirty seconds. If it cannot renew, it stops issuing references until it can claim a number again. The reference column has a unique constraint, so a duplicate would be an error at insert time instead of a misdirected email. We corrected the tracking history of the thirty seven pairs by hand and wrote to the customers involved.&lt;/p&gt;

&lt;p&gt;The design had leaned on a property of our network, not of the generator. Moving it to a new network quietly took that property away.&lt;/p&gt;

&lt;p&gt;– Sergey Shinder&lt;/p&gt;

</description>
      <category>sergeyshinder</category>
      <category>kubernetes</category>
      <category>java</category>
      <category>distributedsystems</category>
    </item>
  </channel>
</rss>
