News for hackers. Stuff that matters.
Re:How Figma's databases team lived to tell the scale by adastral on Thursday March 14, 2024 @02:38PM (#39707447)
I see they don't mention Citus (https://github.com/citusdata/citus), which is already a fairly mature native Postgres extension. From the details given in the article, it sounds like they just reimplemented it.

I wonder if they were unaware of it or disregarded it for a reason —I currently am in a similar situation as the one described in the blog, trying to shard a massive Postgres DB.

Re:How Figma's databases team lived to tell the scale by gshulegaard on Thursday March 14, 2024 @03:47PM (#39708203)
I have worked on teams that have both sharded and partitioned PostgreSQL ourselves (somewhat like Figma) (Postgres 9.4-ish time frame) as well as those that have utilized Citus. I am a strong proponent of Citus and point colleagues in that direction frequently, but depending on how long ago Figma was considering this path I will say that there were some very interesting limitations to Citus not that long ago.

For example, it was only 2 years ago that Citus allowed the joining of data in "local" tables and data retrieved from distributed tables (https://www.citusdata.com/updates/v11-0). In this major update as well, Citus enabled _any_ node to handle queries, previously all queries (whether or not it was modifying data) had to go through the "coordinator" node in your cluster. This could turn into a pretty significant bottleneck which had ramifications for your cluster administration and choices made about how to shape your data (what goes into local tables, reference tables, or distributed tables).

Again, huge fan of Citus, but it's not a magic bullet that makes it so you no longer have to think about scale when using Postgres. It makes it _much_ easier and adds some killer features that push complexity down the stack such that it is _almost_ completely abstracted from application logic. But you still have be cognizant of it, sometimes even altering your data model to accommodate.

Re:How Figma's databases team lived to tell the scale by gen220 on Thursday March 14, 2024 @04:35PM (#39708651)
You also benefit from the tailwind of the CitusData team making continued improvement to the extension, whereas an in-house system depends on your company's ability to hire and retain people to maintain + improve the in-house system.

It's hard to account for the value of benefits that have yet to accrue, but this kind of analysis, even if you pretty heavily-discount that future value, tilts the ROI in favor of solutions like Citus, IMO. Especially if your time horizon is 5+ or 10+ years out.

Like you said, if they made this decision 3ish years ago, you would have had to be pretty trusting on that future value. A choice, made today, hinges less on that variable.

Re:How Figma's databases team lived to tell the scale by wayne-li2 on Thursday March 14, 2024 @05:21PM (#39709128)
Huh, I would have thought the opposite. Companies at Figma size are easily able to hire talent to maintain a core part of their engineering stack. On the other hand, they retain no control of Citus decision making. Those tailwinds could easily have been headwinds if they went in a direction that did not suit Figma.
Re:How Figma's databases team lived to tell the scale by gen220 on Friday March 15, 2024 @05:04PM (#39720692)
I think this is true for things higher up the "stack", but doesn't necessarily apply to tech like Postgres [and Citus, IMO].

The line separating "build in-house" vs "use OSS" exists, and it's at a different layer of the stack in every company. IMO, for most companies in 2024, the line puts Citus on the same side as Postgres.

FWIW, I would have assumed that Citus would be on the other end of the line, until I had to look into Citus for work for a similar reason that Figma did. You can pick and choose among the orthogonal ideas they implement that most cleanly apply to the present stage of your business, and I would've chosen to build things the same way they did (TBH, Figma's choices superficially appear to be 1:1 to Citus's choices).

Re:How Figma's databases team lived to tell the scale by sgarland on Thursday March 14, 2024 @03:03PM (#39707708)
I thought of that as well. The only thing I could think of is that they mentioned that they don't want to move off of RDS, and there is 0% chance of Citus coming to AWS since Microsoft bought them.
Re:How Figma's databases team lived to tell the scale by jabart on Thursday March 14, 2024 @03:21PM (#39707917)
Figma uses AWS RDS, RDS doesn't list citus as a supported extension.
Re:How Figma's databases team lived to tell the scale by gen220 on Thursday March 14, 2024 @04:31PM (#39708608)
This is my guess of why they didn't use Citus. They weren't interested in the options of (1) going multi-cloud [DB in Azure Cosmos / Backend(s) in AWS] (2) going all-in on Azure [DB in Azure Cosmos / Backend(s) in Azure] (3) self-managing Postgres+Citus in EC2.

It'd be interesting to compare the expected capex of developing this in-house solution + the opex of maintaining it vs the same categories of expected costs for option (3) – because I imagine that's probably the most palatable option.

They also may have pre-paid for dedicated RDS instances for the next X years (before this horizontal scaling initiative began, to boot), as AWS allows companies to do this at a pretty steep discount rate, which would probably tilt them away from (3).

Re:How Figma's databases team lived to tell the scale by sgarland on Thursday March 14, 2024 @05:58PM (#39709445)
Especially because Option 3 lets you go waaaay farther on vertical scaling, since you can get native NVMe drives (they mentioned hitting IOPS limits for RDS), more exotic instance classes with far more RAM, and do stuff like ZFS for native compression and snapshots.
Re:How Figma's databases team lived to tell the scale by junto on Thursday March 14, 2024 @03:01PM (#39707690)
Before clicking on the article I assumed it was Citus, and was surprised when it wasn’t.

Maybe because CitusData was bought by Microsoft around the same time, so Microsoft could create “Azure Cosmos DB for Postgres Cluster”, yet another one of Microsoft’s typical product naming crapshoots.

Re:How Figma's databases team lived to tell the scale by victor106 on Thursday March 14, 2024 @04:03PM (#39708349)
> yet another one of Microsoft’s typical product naming crapshoots.

Well said. I haven't seen any company as terrible as Microsoft at naming things. Anyone know why?

Re:How Figma's databases team lived to tell the scale by studmuffin650 on Thursday March 14, 2024 @05:04PM (#39708956)
AWS is putting up good fight
Re:How Figma's databases team lived to tell the scale by salynchnew on Thursday March 14, 2024 @05:18PM (#39709093)
Naming things is hard.

At a previous employer, I saw several cool-ish open source projects instantly doomed to obscurity by picking a name that either completely duplicated the name of an existing OSS project or were guaranteed to have terrible SEO for another reason.

However, Microsoft seems to have a unique crossover of fragmented business units and centralized marketing. That's why you end up with Azure -> Subproject -> Actual Product/Service word soup. Perviously, they did this with the Windows Live brand from 2005-2012, and "Xbox" for a wide range of gaming projects (many of which were on PC).

Re:How Figma's databases team lived to tell the scale by thomasjudge on Thursday March 14, 2024 @06:55PM (#39709947)
related, Microsoft on Microsoft marketing:

https://www.youtube.com/watch?v=EUXnJraKM3k

Re:How Figma's databases team lived to tell the scale by r-bar on Thursday March 14, 2024 @07:07PM (#39710060)
The committee wanted Cosmos, Azure, and Postgres all in the name and wouldn't compromise.
Re:How Figma's databases team lived to tell the scale by iamdanieljohns on Thursday March 14, 2024 @02:48PM (#39707543)
I would love to see a comparison of the major PostgresQL services such as Citus, EDB, Crunchy, Neon, and some OSS distributions/packages
Re:How Figma's databases team lived to tell the scale by _boffin_ on Thursday March 14, 2024 @02:42PM (#39707488)
how "massive" is massive in your case?
Re:How Figma's databases team lived to tell the scale by dijit on Thursday March 14, 2024 @02:49PM (#39707557)
I've had CitusDB running across 68 bare metal machines (40 vCPU, 768GiB ram, 20TiB of storage each + 40GiB network links) and it ran decently well.

Not sure what your definition of massive is, I think Spanner would easily beat it.

Also, it's very use-case dependent, you can't "just use" Citus for everything, it's not quite as flexible as a bog-standard pgsql install due to the way it's sharding, you have to be a tad more careful with your data model.

Re:How Figma's databases team lived to tell the scale by skunkworker on Thursday March 14, 2024 @04:52PM (#39708831)
What is your definition of "decently well", and is your primary cluster (without replicas) above 1PB?
Re:How Figma's databases team lived to tell the scale by simonw on Thursday March 14, 2024 @05:37PM (#39709269)
They said 20TiB * 68, which I think is 1.5PB.
Re:How Figma's databases team lived to tell the scale by skunkworker on Friday March 15, 2024 @05:09PM (#39720735)
That could be all of the nodes, or just the primaries without replicas.
Re:How Figma's databases team lived to tell the scale by VHRanger on Thursday March 14, 2024 @09:57PM (#39711320)
Is there a reason there's comparatively little storage in your machines in relation to RAM or even CPUs?

Do your machines do compute heavy loads or something?

For a DB I'd expect a lot more storage per node

Re:How Figma's databases team lived to tell the scale by dijit on Friday March 15, 2024 @12:10AM (#39711992)
NVMe SSDs aren't so large unfortunately.

a 1U server has capacity for 8 drives, we used 2 slots for the OS (RAID1), 2 slots for the WAL volume (2 slots) leaving only 4 slots in RAID10.

So I'm already cheating a little and claiming WAL storage was part of total storage.

Re:How Figma's databases team lived to tell the scale by VHRanger on Friday March 15, 2024 @08:50AM (#39714937)
Shouldn't you try to get something with PCIe bifurcation in this case?

I doubt you're saturating the PCIe bus bandwidth on any of them?

I imagine your DB is extremely high performance, though!

Re:How Figma's databases team lived to tell the scale by adastral on Thursday March 14, 2024 @02:49PM (#39707551)
Around ten heavily-updated (50-400k updated rows/min) tables ranging between 500M and 5B rows, with a couple tables over 40B rows each (5TB each IIRC).
Re:How Figma's databases team lived to tell the scale by gregors on Thursday March 14, 2024 @04:29PM (#39708579)
Where's the fun in that? I'm not being snarky either. Maybe it's not the best decision business-wise, but I guarantee it was more challenging and more fun. There's something to be said for that.