Serving your CSS/JS from a different subdomain (assets.mydomain...) than your document (www.mydomain...) is costing you 100+ milliseconds on your LCP for no good reason. Here's how to use DevTools to inspect and repro this, and why you need to use chrome://net-internals:
• • •
Missing some Tweet in this thread? You can try to
force a refresh
ActiveRecord performance puzzle: "SELECT <long-list-of-columns>" sometimes takes ~10-40x longer than "SELECT *", randomly. Issue is not at the database, where query is consistently <1ms. Issue reproduces in Rails console.
Basically run it 10x in the console and you'll see 1ms, 1ms, 1ms, 40ms, 1ms, 1ms, 40ms, 1ms, 1ms.
More data: it isn't GC, it doesn't appear to be logging, and it does not occur in production
and yes, in k8s, this would be per-pod, horizontal pod autoscaler running on top of that with request queue time as the metric
8GB for 4 workers is probably more memory overhead then you're ever gonna need but that 1vcpu:2GB ratio is the lowest that most cloud vendors sell so lower memory usage doesn't get you much.
I put in a big PR to speed up my client's most important background job by 10-30%. This was really important because it generates 90%+ of their load. Let me walk you through it, commit-by-commit. (1/6)
First, we write some simple scripts to benchmark and profile the code in question. I used Benchmark from stdlib here because running this code once takes about 40 seconds. Note the warmup and use of transactions. github.com/WikiEducationF… (2/6)
Next, we fix an N+1. This is an example of what I call an "Enumerable" refactoring for an N+1. Rather than use the DB to do things like sum a column, we do it in Ruby. This is faster here b/c we were already going to load all the data anyway. github.com/WikiEducationF… (3/6)
All of these qualities are not ineffable. We can (and should) quantify them: LOC, dependency LOC, hours spent fixing bugs and dealing w/incidents, and server costs. Your customer has requirements for these. You don't need to magically guess them on their behalf: you have to ask.
Craftsperson attitude is about delivering the highest possible software quality regardless of customer requirement. This is wrong. You should deliver what the customer requires: no more and no less.
And of course, you are the expert: so it's your role to help shape these requirements. Customers can be misguided about what scalability they require (usually they overestimate), or what maintenance they'll need to do (usually they underestimate).