[HN Gopher] How Convex Works
       ___________________________________________________________________
        
       How Convex Works
        
       Author : tim_sw
       Score  : 67 points
       Date   : 2024-04-13 04:33 UTC (1 days ago)
        
 (HTM) web link (stack.convex.dev)
 (TXT) w3m dump (stack.convex.dev)
        
       | sujayakar wrote:
       | hey, sujay (the author) here! happy to answer any questions about
       | the post or convex more generally.
        
         | nextworddev wrote:
         | Hey there! Seems like a BaaS product. What problem areas do you
         | think Convex solves the best among other alternatives?
        
           | xixixao wrote:
           | 1. Consistent reactive UI - better UX and better DevX
           | 
           | 2. Transactional by default - avoids concurrency bugs in
           | production
           | 
           | 3. End-to-end type safety, best-in-class TypeScript support
           | for React and the backend
           | 
           | 4. Explicit indexing for predictable backend performance in
           | production (no unexpected deopts)
           | 
           | 5. Super fast DevX: Save and have your code deployed.
           | Flexible (optional) schema. Powerful reactive dashboard.
           | 
           | 6. Feature-full: File storage, scheduling, text search,
           | vector search all built in.
           | 
           | On the cons side: Auth story isn't as streamlined as for
           | Firebase or Supabase if you don't want to use Clerk or Auth0.
           | But we're working on it!
        
         | waldrews wrote:
         | How would you approach audit trail/soft delete scenarios?
        
           | xixixao wrote:
           | Since it's really application specific (what rows should be
           | soft deleted, is recovery possible...), you probably want to
           | model these like any other state. With Convex you can do
           | things like schedule a deletion mutation 30 days from now, or
           | run a cron job that cleans up data out of retention.
           | 
           | Is this what you had in mind?
        
             | waldrews wrote:
             | I guess I'm just wishing for an insta-backend with a
             | database layer that's auditable/temporal by default (like
             | Datomic). Guess that's orthogonal to the problems you're
             | solving.
        
               | xixixao wrote:
               | This is kind of how Convex works under the hood, and so
               | we might add more temporal/auditing functionality in the
               | future (like a time-traveling debugger).
               | 
               | You could also implement this on top of Convex, if it
               | makes sense for your write volume.
        
       | jitl wrote:
       | Did yall build all the database implementation components
       | yourself, or are any of them open source / off the shelf? It
       | sounds like Kafka could do the transaction log job, and overall
       | the architecture sounds similar to XTDBv1 which does use Kafka
       | for that component.
       | 
       | https://v1-docs.xtdb.com/concepts/what-is-xtdb/
       | 
       | I'm also curious if you support unique constraints on non-id
       | columns, or if having writer actions close to the database kind
       | of takes that role.
        
         | xixixao wrote:
         | We open-sourced a single-machine version of the backend:
         | https://github.com/get-convex/convex-backend
         | 
         | It doesn't use Kafka, the transaction logic is custom
         | implemented in Rust.
         | 
         | Convex does not have special support for unique constraints, as
         | they are easy to implement in your own code (like you wrote,
         | the mutations are happening "inside" the database). This
         | follows the philosophy of making it clear what the database
         | primitives are, and hence what performance you can expect from
         | the database.
         | 
         | Of course since your code is all JavaScript/TypeScript, it's
         | easy to layer in constraints via a library, like in
         | https://labs.convex.dev/convex-ents/schema#unique-fields
        
         | james_cowling wrote:
         | Convex cofounder here. Yep the database transaction logic,
         | timestamp assignment, concurrency control, etc is all custom.
         | This is a pretty key requirement in our ability to perform
         | dynamic subscriptions and automatic caching in real time.
         | 
         | Internally the very bottom of the stack on the hosted product
         | is actually just a write ahead log on RDS and in the open
         | source product it's just sqlite. We'll likely eventually build
         | our own durable write ahead log, and have plenty of experience
         | doing so, but this hasn't been needed so far.
        
       | naphatkrit wrote:
       | Great workflows! If I was starting a new project today, what are
       | the cases where I should consider Convex vs. not?
        
         | xixixao wrote:
         | If you need a database for online workloads (ie, your users
         | interact with your product via reading and writing data to the
         | database) and are ok with writing your backend in JavaScript or
         | TypeScript, you should consider Convex.
         | 
         | If you need for example peer-to-peer video or machine-learning
         | inference, these are not well suited to building on Convex from
         | scratch, but you can likely use Convex to implement the rest of
         | the app (and probably use another service for these).
         | 
         | Since Convex is online and realtime, it doesn't focus on
         | domains like embedded systems programming or analytics (but you
         | can stream data from Convex to an analytics platform).
        
       | qwertyuiop_ wrote:
       | How can we be sure you are going to be around when the inflation
       | hits 9% and interest rates go up to 15% ? This is a serious
       | question because whoever invests time in building on your backend
       | which is not open source are taking extreme risks.
        
         | james_cowling wrote:
         | (convex cofounder here)
         | 
         | Convex is in a very comfortable financial position but it is
         | also open source: https://github.com/get-convex/convex-backend
        
       | huevosabio wrote:
       | I say this every time convex comes up in a conversation: by far
       | my favorite stack for building web apps.
       | 
       | The developer experience is really polished.
       | 
       | I haven't deployed any major apps yet, so unsure how the costs
       | scale VS deploying your own or other BaaS offerings.
       | 
       | The team is incredibly skilled and great people.
        
         | ikhare wrote:
         | Thanks for the kind words. Feel free to share any feedback in
         | the discord community!
        
       | Lt_Riza_Hawkeye wrote:
       | Curious about the choice to send requests with WebSocket
       | connections instead of just plain old POST forms. This precludes
       | anyone with javascript disabled from using any of these sites. I
       | don't think there's anything in the business logic preventing it
        
         | ikhare wrote:
         | You can use http directly for your functions [1]. Or you can
         | create custom http actions [2]. We encourage websocket usage
         | because it allows for reactivity and UI consistency and it
         | plays nicely with reactive frontend frameworks like React etc.
         | 
         | [1] https://docs.convex.dev/http-api/#functions-api [2]
         | https://docs.convex.dev/functions/http-actions
        
         | thomasballinger wrote:
         | HTTP handlers for requests can be defined, many Convex apps
         | define these to handle webhook notifications and some apps
         | consist primarily of these endpoints or app-specific REST APIs.
         | (I work at Convex)
         | 
         | Edit: simultaneous post with my manager
        
       | wslh wrote:
       | I am now very curious about Convex.
       | 
       | Supposing it is great, how business locked are you if you decide
       | to use it?
        
         | sujayakar wrote:
         | we just open sourced the backend last month!
         | https://news.convex.dev/convex-goes-open-source/
        
           | wslh wrote:
           | Could you please be more verbose about the licensing scheme
           | and what it means for a company to decide to use Convex
           | without the intention of paying right now?
           | 
           | For example, a corporation asks my company to build a fintech
           | product that will be used by more than a million people in
           | less than one year, we need to decide to use Convex or not,
           | in the current licensing scheme how locked are we? Even if
           | it's open source.
           | 
           | It is not that we don't want to pay for adding value to the
           | whole product but there are a many options to choose.
        
       ___________________________________________________________________
       (page generated 2024-04-14 23:01 UTC)