2,564 karma · joined November 25, 2013
You can reach out to me at r@ena.to
https://github.com/renatomassaro
> multi-tenant-safe cache keys
> on a server-rendered app
> byte-for-byte identical (classic)
> gets a cache-speed response
> cached-file-extensions list
Honestly, this is terrible. I had to add a "use simple words only, don't hyphenate unnecessarily" warning to my Claude config. After a full day of work, having to read these Claudisms all the time make a noticeable difference on how tired you get. It gets even worse when Claude starts to make up its own vocabulary.
I surely missed a valid API token today.
Seems great on paper, but quickly turns into a nightmare. Magic is great to get you up to speed, but as soon as you find yourself having to bend the magic, good luck.
I review this kind of AI-generated Elixir code on a daily basis. And it makes me want to go back to ~2022, when code in pull requests actually made sense.
Apologies for the rant, this is just a burnt out developer tired of reviewing this kind of code.
PS: companies should definitely highlight "No low-quality AI code" in job listings as a valid perk.
Mostly as a fun experiment, but also from the realization that every place I worked at in the past (small/medium-sized B2B startups) would greatly benefit from such architecture.
Yes, there are massive trade-offs to this approach, and the concerns raised in the comment section are valid. This doesn't mean the database-per-tenant is never worth it. There's a sweet spot for it, and if it fits your business/application, I personally would consider it a technical advantage over competitors.
My goal with FeebDB is to eliminate or reduce the common pain points of database-per-tenant, including:
- ensure there is a single writer per database.
- improved connection management across all tenants (e.g. only keep open at most 1000 DB connections, similar to an LRU cache).
- on-demand migration (all shards are migrated on application startup, but if a shard that hasn't migrated yet receives a request, it will first perform the migration and then serve the request),
- on-demand backups and replication (e.g. the library knows which shards were updated in the last X minutes, so it can trigger Litestream or similar on demand).
- support for enumeration of databases (performing map/reduce/filter operations across multiple DBs)
- support for clustered deployment with "pinned" tenants (for now I'm assuming the IOPS of a single beefy server should be enough for all use cases, but once that's no longer sufficient you can have "shards of shards")
How can this ever be acceptable?
Demo: https://demo.ryot.io/_s/acl_vUMPnPirkHlT
Code: https://github.com/IgnisDa/ryot
(PS: they opted to go in a direction where it also includes some media-related features -- like tracking movies or books you've seen/read -- but this can be disabled).
These breaks were taken at a "natural" time, when you felt one was needed. By definition, an interruption is a "break" when you don't want one.
I actually have two projects that use this approach, FeebDB (which is the library I wrote to manage a "one SQLite database per client" approach) and HackerExperience (a game under development that uses FeebDB).
The overall idea is simple:
1. Before tests start running, create a prop of each database.
2. The prop contains the "starting database" for each test. It may contain seed data (optional).
3. For each test, copy the prop and assign it a unique shard identifier (say, cp /props/user.db /test_data/user/874125.db).
4. The test knows the `shard_id` and can do whatever it wants with it; no one else will bother it.
5. Once ExUnit is finished, delete all shards.
Both projects follow a similar approach (I wrote it first in FeebDB and copied into HackerExperience, which has some sections commented out -- I need to clean up this part of the codebase).
For both projects, you will find steps 1/5 in `test/support/db.ex`, step 2 in `test/support/db/prop.ex` and steps 3/4 in `test/support/case/db.ex`.
- FeebDB: https://github.com/renatomassaro/FeebDB/
- HackerExperience: https://github.com/HackerExperience/HackerExperience/
Email is in profile in case you have follow up questions/comments :)
This kind of setup makes the usual Ecto Sandbox approach feel slow, but I do agree that the way Elixir approaches this is great!
It will hurt even more.
The recommended way is to set up a witness server. Yet another thing to manage in a properly designed Postgres cluster. Certainly not an easy/trivial thing to do, ops-wise.
From [0]:
> By creating a witness server in the same location (data centre) as the primary, if the primary becomes unavailable it's possible for the standby to decide whether it can promote itself without risking a "split brain" scenario: if it can't see either the witness or the primary server, it's likely there's a network-level interruption and it should not promote itself. If it can see the witness but not the primary, this proves there is no network interruption and the primary itself is unavailable, and it can therefore promote itself (and ideally take action to fence the former primary).
An interesting acronym you'll hear is STONITH (in order to fence the former primary).
[0] - https://www.repmgr.org/docs/current/repmgrd-witness-server.h...
I think iocage was released after v8, so yes, definitely! Not only creating, but managing jails as a whole. In many ways, iocage can be compared to docker when it comes to container management.
Many years ago I migrated to FreeBSD and absolutely loved it. I was forced to migrate back to Linux once I started a job and ended up staying with Linux to this day.
A few months back I decided to give FreeBSD another shot. The one thing that was an immediate deal breaker was being unable to suspend/resume on my desktop computer. For my workflow, that's an unnecessary waste of power / energy.
Just wanted to share this testimonial to outline the importance of suspend/resume for non-laptop hardware. Almost every time I see this discussion, it's focused on laptops.
By the way, I'm extremely excited about this initiative to make FreeBSD more attractive to non-server users in general (not only new ones). That will surely be a huge benefit to the entire community. If I can't run FreeBSD on my machine, I won't runt it on my servers.
Of course there are a multitude of variables we don't have access from the outside, but Postgres only compresses data that is TOASTed, and based on your description of the table, the data is not being TOASTed (and therefore not being compressed).
Instead, if you could somehow pack your timeseries entries into an array, you would get the benefits of compression automatically.
Given your write performance requirements, using an array may be out-of-question (and you may get too much overhead from dead tuples) -- but who knows? Always a good idea to benchmark.
I actually considered mentioning this at the post but figured it was too long already and could be the material for a future one :)
> Indexes are, by nature, a tradeoff where you give up space to gain time, so this mindset doesn't really apply there.
I agree that (re)aligning indexes are a different beast entirely, but (as mentioned in my recommendation) ideally the developer should keep this in mind when creating the index initially.
Factors like cardinality and even readability should take precedence over perfect alignment, but all else being equal, aligning your indexes from the very moment they are introduced in the codebase is the ideal scenario IMO.
I totally agree (and have seen both scenarios throughout my career).
That said, all else being equal[0], refactoring the purely functional code is, usually, easier, more reliable and less scary.
[0] - among other things, this assumes the person doing the refactoring knows, in this example, both Python and Haskell equally well.
If Bolsonaro had not made fun of covid victims and needlessly spilled hate on every other word that came from his mouth, he'd be the current president of Brazil.
A moderate right wing candidate will likely win for 2026, just like an hypothetical moderate Bolsonaro would have won last year.
I have my own take, but then again it is heavily influenced by my own bias. It's hard to share an unbiased opinion here.
The idea that Lula is using his political power to take Bolsonaro out of the game is laughable, IMO.
For the next presidential election, any not-too-exteme right wing candidate has great odds of beating Lula, if he were to run for reelection.
> This is not a numbered fatal event because the Legacy aircraft, although based on the design of the ERJ135 regional airliner, was not airline passenger flight.
This particular crash is widely known here in Brazil. The two pilots from the small aircraft had turned off the plane transponder. They had a mid-air collision with a 737. Everyone at the 737 died.
The two pilots of the Embraer 190 are Americans. They were sentenced to jail in Brazilian court but were never arrested to this day (not sure why).