A neighbor’s bulk job drained every ephemeral port on a shared box. Twice. Here’s the one kernel setting that would have stopped it — and the architecture that makes it a non-issue.At 1:38 AM, one of our background-job services started failing. Scheduled jobs — the nudges and reminders we send users overnight — began throwing an error most engineers rarely see:Errno::EADDRNOTAVAIL — Cannot assign requested addressNot “connection refused.” Not “timeout.” Cannot assign requested address. The machine wasn’t saying the other end was down. It was saying it had run out of addresses to call…
I was working with a readonly model in Rails the other day and ran into an issue whilst testing it. Here's what I ran into and the solution I came up with. Readonly models are a great way to signal that, well, you should only ever read them, not write them. Maybe you have some external system that connects to the database for writes, or maybe your Rails app connects to some data warehouse for some queries or reports. It's can be useful to have a safeguard to prevent accidental errant writes. It's actually really simple to make a model readonly, you just need to override the readonly? method:…
Choosing good names for objects and methods in code is one of the toughest things to do as a software engineer. It comes with the great and invisible reward of simplicity – second only to having less code in the first place, having code that’s easy to reason with makes extending it and debugging it in […]
Introduction We recently encountered an interesting problem when using Turbo Streams to update part of a complex nested form in FreeAgent’s main Ruby on Rails web application. For those unfamiliar, nested forms allow a user to enter data relating to both a main parent object and its associated objects. This could be, for example, a […]
N+1 queries are one of the most common performance killers in Rails apps, but also one of the easiest to fix. In this post, we'll see how a single line of code can reduce 1,101 database queries down to 3. N+1s occur in rails when you have associated ActiveRecord models, and iterate over one model while accessing fields on the associated records. This might be easier to explain with an example. Let's say you have the following ActiveRecord models: class Author ApplicationRecord has_many :posts end class Post ApplicationRecord belongs_to :author has_many :tags end class Tag ApplicationRecord…
Hotwire is central to how we drive the frontend at FreeAgent, and Action Cable allows us to send Turbo Streams as users browse the site, adding a layer of richness to the user experience.
Optional Google Analytics helps us understand visits. Microsoft Clarity records masked interactions to improve the site. Optional tools stay off unless you choose them. Privacy details.