#Higher Storage usage by convex compared to turso

24 messages · Page 1 of 1 (latest)

rotund lintel
#

I imported the same json (22kb) to turso and convex (no indexes in convex, some indexes in turso but that makes no difference for the argument)

And Turso requires space like 27 mb compared to convex with 144.06 mb.

This problem gets exponentially worse if you add indexes which duplicate the data.

Why does Convex take so much more space?

tidal breach
#

two reasons:

  1. Convex adds _id and _creationTime fields to each document, so it's not just the raw json you're storing
  2. Document sizes are rounded up to the nearest kilobyte https://docs.convex.dev/production/state/limits#database

the reason for (1) is to access your documents via db.get you need a unique id field and to query documents in the default order they need a creation time field.

The reason for (2) is that there is some per-document overhead within Convex, e.g. when reading a small document you often need to do IO for an entire 4kb page of SSD storage. However, we're rethinking this policy internally and may remove the rounding soon.

basically, the accounting policy is trying to be honest about how expensive small documents are, and incentivize good patterns. But also look forward to changes here soon 😊

We’d love for you to have unlimited joy building on Convex but engineering

rotund lintel
tidal breach
#

How big are your documents? i would guess that rounding each document up to 1kb is a bigger factor

rotund lintel
tidal breach
#

147 thousand documents * 1kb per document comes out to 147mb, so that explains it 😝

tidal breach
#

I wouldn't worry about refactoring, since we're probably going to remove the 1kb thing soon

#

(i'm bumping the internal discussion now)

rotund lintel
rotund lintel
tidal breach
#

curious, is an extra 100mb pushing you over the limit? i believe the limit is 500mb

rotund lintel
#

this problem is not a big deal initially but it's growing exponentially

tidal breach
#

ok i'll re-enable your team. even without the 1kb rounding, it's around 40mb to store the data, multiplied by indexes and deployments. if you want to keep usage low, i would recommend using smaller datasets in dev deployments.

rotund lintel
oblique grail
tidal breach
oblique grail
#

Thanks @tidal breach. The reason I ask is because of financial planning. It seems from your comment and the article that branching in Convex is fundamentally about branching the schema, and not the business data. So just to be clear: if you branch production, and then seed the new branch with the same data as in production, would a Convex customer be billed for double the storage usage?

#
  1. Also @tidal breach, a lower priority question: there's no automatic copy to a preview deployment today, but is it on the roadmap to make a copy-on-write branch that is a clone of production Convex deployment?
steel ingot
#

Each deployment is essentially a blank new database. So whatever data you put in a new deployment (dev, preview, prod) will count towards your overall quota for the team.

#

We don't have copy-on-write branches in the roadmap yet. It's something we've discussed but haven't put it on any list yet.