Jared Moody

Jared Moody

@jaredmoody.com

I like Ruby, roasting coffee, Oxford commas, and dad jokes.

413 followers69 following105 posts

You either die a hero, or you live long enough to get purchased by salesforce, be neglected for years, try to squeeze your customers for enterprise contracts, give them false hope of a new platform only to pull the rug and declare maintenance mode. RIP #heroku #rails #ruby

Just scaled the last dyno of our rails app to 0. Might write up a thread but we're now running on AWS, provisioned with #OpenTofu, deploying with #kamal. Gradually moved traffic a via CloudFlare load balancer over the last week and so far so good. AMA.

Jared Moody reposted

Alongside the Ruby 4.0 release last week, I published charm-ruby over Christmas, bringing @charm.land's excellent terminal UI libraries to Ruby. A full TUI framework, reusable components, styled output, forms, markdown rendering, spinners, charts, and a lot more! Demos below ⬇️

Been running #bazzite for several months now on a mini pc and it is just solid. All my games just work, and the Steam Gaming Mode is great on the TV. 5/5 stars, would install again.

So since #mozilla clarified/tweaked the changes to the #firefox TOS, are we keeping calm and firefoxing on now? I'm at the same time grateful for those who saw this and raised a fuss AND I think lots of options are good, yet I find the frantic throw hands up "now we have to fork" energy exhausting.

I deployed #solidcache into production today. In the past I've asked around about what kind of performance people had been seeing and gotten back nothing, so, a quick thread about my experience, and a subtle gotcha to avoid if pre-warming/transferring. #ruby #rails

View full thread

So, to deal with this, I used some private APIs (danger!) to read out and de-serialize the Cache::Entry objects (with their versions intact!), not the actual values that Rails.cache.read / read_multi returns. Then I wrote those entries out just like the Cache Store does under the hood.

I deployed #solidcache into production today. In the past I've asked around about what kind of performance people had been seeing and gotten back nothing, so, a quick thread about my experience, and a subtle gotcha to avoid if pre-warming/transferring. #ruby #rails

View full thread

The unintended result of this is that the cache for the user does not bust when the AR object is updated because Rails has no version to compare with. Rails.cache.read [@user, 'greeting'] will return the stale value even after @user is updated.

In the good old days™️ when the AR object timestamp was a part of the cache key, this wouldn't have mattered, but, cache space was also used less efficiently. Recyclable cache keys are more complex, but a net positive IMO.

I deployed #solidcache into production today. In the past I've asked around about what kind of performance people had been seeing and gotten back nothing, so, a quick thread about my experience, and a subtle gotcha to avoid if pre-warming/transferring. #ruby #rails

View full thread

Given a User ActiveRecord with an id of 1, Rails.write [@user, 'greeting'], 'hello' and Rails.write 'users/1/greeting', 'hello' both write a serialized Cache::Entry object with a value of 'hello' to the same cache location.

I deployed #solidcache into production today. In the past I've asked around about what kind of performance people had been seeing and gotten back nothing, so, a quick thread about my experience, and a subtle gotcha to avoid if pre-warming/transferring. #ruby #rails

View full thread

A fancier approach might have been to write a custom store to dual-write, but I was ok with losing the cache writes from the time it took the pre-warm to run.

This approach appeared to work at first, but has a _very_ subtle bug: Writing to the rails cache with an AR object is almost but *NOT* equivalent to writing to the same cache key.

I deployed #solidcache into production today. In the past I've asked around about what kind of performance people had been seeing and gotten back nothing, so, a quick thread about my experience, and a subtle gotcha to avoid if pre-warming/transferring. #ruby #rails

View full thread

What surprised me though was that the 5GB I copied only used ~ 2.25GB of DB Storage in SolidCache. Dug into the source a bit, and the SolidCache Store is doing some compression that the RedisCacheStore is not. So we're looking at effectively 10x the size.

Now the gotcha. I pre-warmed SolidCache in a very naive manner - just get keys from redis with SCAN, read the values for those keys out of the redis store with `read_multi` and write them out to the solid cache store with `write_multi`

I deployed #solidcache into production today. In the past I've asked around about what kind of performance people had been seeing and gotten back nothing, so, a quick thread about my experience, and a subtle gotcha to avoid if pre-warming/transferring. #ruby #rails

View full thread

As expected, better hardware is faster. The prod Redis cache pulled 1k keys averaging 0.528ms per key (while also serving prod requests), SolidCache in 0.752ms per key. Seems SolidCache is plenty fast for web applications.

For 0 additional cost of what we're already paying for our (perhaps slightly over-provisioned) RDS cluster, we've got a negligibly slower cache, with 5x the storage (started with a max_size config of 25GB) and room to expand.

I deployed #solidcache into production today. In the past I've asked around about what kind of performance people had been seeing and gotten back nothing, so, a quick thread about my experience, and a subtle gotcha to avoid if pre-warming/transferring. #ruby #rails

View full thread

Excited, I deployed to prod (while keeping the old cache store in place), copied ~ 4M cache entries from Redis over into SolidCache and ran my read tests again, but this time against a much beefier db.m6gd.2xlarge cluster - *with* directly attached storage.

I deployed #solidcache into production today. In the past I've asked around about what kind of performance people had been seeing and gotten back nothing, so, a quick thread about my experience, and a subtle gotcha to avoid if pre-warming/transferring. #ruby #rails

View full thread

Then I did 1k reads or writes and summed the times from Benchmark.ms. Not scientific but enough to get an idea. Writes were about 2x slower, which sounds bad, but we're talking like 5ms vs 2.5ms, not enough to matter.

Reads were even closer, in some tests SolidCache was actually faster, but I'm sure I was overwhelming that little Redis server. I averaged 2.5ms reading 1k keys one at a time from SolidCache - which would do fine.

I deployed #solidcache into production today. In the past I've asked around about what kind of performance people had been seeing and gotten back nothing, so, a quick thread about my experience, and a subtle gotcha to avoid if pre-warming/transferring. #ruby #rails

At <day job>, our app servers are on Heroku, our database an RDS #postgresql cluster, and our old #redis cache was on the very solid but very expensive RedisToGo. We're talking $500/mo for 5GB of redis memory. Yikes.

To prove out if solid cache was going to work for us at all, I first deployed to a very smol staging server (app server 1GB, RDS t4g, RedisToGo free plan) and tested some reads/writes. I seeded the cache with about 50k cache entries of real cache data - some just cached totals, some HTML fragments.

This week I learned about VPN on demand in iOS which is pretty nifty! I’ve now configured Tailscale to kick in on my phone whenever I leave my home WiFi network so I have ad-blocking via #pihole automatically, always. 10/10, would recommend.

You crazy bastards, I won’t be awake but I’m in.

patak@patak.cat

I just saw @mattpocockuk.bsky.social's post, and I wonder if a flash mob where we all post a 🦋 at the same time in X could make some ripples. As in scheduling a post for tomorrow, October 31, 7 am PST 👀