5 ms·
Edge-compatible Serverless Driver for Postgres
- nikita 4y agoI’m Neon CEO. Happy to answer questions. We also have an interesting roadmap for the driver where we hope to keep driving latency and number of round trips down
- pbiggar 4y agoDoes Neon scale down storage? I'm paying GCP a lot for storage I don't use, and it's incredibly frustrating - they scaled me up no problem but won't let me scale down.
- nikita 4y agoStorage is multi tenant and bottomless. Unused storage spills to S3 and is cheaper. We pass savings to our users
- bilalq 4y agoI don't see pricing listed anywhere. Can you expand on what that might look like? Also, can Neon scale down to zero like serverless aurora v1, or is there a minimum capacity unit?
- sakras 4y agoI’m curious why not implement websockets into Postgres natively instead of relying on a proxy server? Wouldn’t that be the way to minimize latency?
- neuronexmachina 4y agoBeing able to connect to arbitrary Postgres servers (or potentially even the postgres compatibility-layers for AWS's Aurora or Google's AlloyDB) seems like a good reason to go for the proxy approach.
- nikita 4y agoYes. Also it was an easier thing to do and ship quickly. We are going to get very tight on latencies and if that would require building it into Postgres we will do so
- jtmarmon 4y agoWould be really cool to see you guys become a managed service on Fly.io - see what they did with Upstash & Redis: https://community.fly.io/t/preview-managed-upstash-redis-with-read-replica-support/6541 https://community.fly.io/t/preview-managed-upstash-redis-wit... They don't have a managed postgres offering yet ("this is not a managed postgres" - https://fly.io/docs/postgres/getting-started/what-you-should-know/ https://fly.io/docs/postgres/getting-started/what-you-should...)
- krashidov 4y agoHey Nikita, what are the key differences between neon and Supabase?
- nikita 4y agoI think we innovate on different parts of the stack. Neon is offering separation of storage and compute and serverless. Theoretically you can run Supabase on top of Neon
- nikita 4y agoTo elaborate Neon is designed deliberately to plug into the Postgres ecosystem. So all of the ecosystem works out of the box. Supabase seems to be vertically integrated. But Paul should comment on that
- kiwicopple 4y agoI believe most of the tools that Supabase use would work with Neon, with the exception of Realtime. As I understand it, Neon doesn't support Logical Decoding yet[0], which is required so that the Realtime engine can receive updates from the database. [0] https://community.neon.tech/t/plans-for-logical-replication/219/2 https://community.neon.tech/t/plans-for-logical-replication/...
- nikita 4y agoYou are right. We will make it work soon
- kiwicopple 4y ago(Another one would be the GraphQL extension: https://github.com/supabase/pg_graphql/ https://github.com/supabase/pg_graphql/)
- Sujan 4y agoThe "How it works" section surprised me - I did not expect to see Websockets there. Other serverless drivers or database APIs (PlanetScale Serverless Driver, AWS RDS Proxy or Prisma Data Proxy) usually use HTTP to replace the stateful TCP connection. The post explains a bit why this might be beneficial (can use existing tools, and use connection state) - but what about the other benefits and use cases of going with HTTP? For example in that architecture the connection pool also moves from the application to the component in between and all that complexity can completely be removed from the app. Especially on serverless platforms, where in theory each request gets its own application with its own pool, that is huge. How does that work here? Or does the pool also move to the "WebSocket-to-TCP proxy" and you just did not highlight it in the post? (The graphic shows a "Connection Pool" but I can not really make sense of what that means.)
- gmac 4y agoRight: at a basic level, using WebSockets lets us change as little as possible from the user perspective. You get an ordinary Postgres session with an ordinary Postgres driver, full control over transactions, and so on. At this point, your serverless function establishes a new Postgres connection on each call. We do pooling on the server side with pgBouncer, which means we can handle lots of simultaneous connections (which is what this approach generates). It's true that this approach doesn't fully optimise for low latencies. But, as Nikita has mentioned elsewhere in this thread, we have a roadmap for bringing latency down in a number of different ways over time.
- Sujan 4y agoOk, so to make that explicit: If I want to do 5 parallel queries on my serverless function I should still have a connection pool size of 5 in my application, which will be fine as PgBouncer ensures there are plenty connections to open and use from the database server side. Correct?
- gmac 4y agoIn principle, yes, but as things stand you'll be starting 5 separate TLS connections to the server that way. My feeling is that this would be an unusual way to use serverless functions. Is it something you think you'd do?
- canadiantim 4y agoWould it ever be possible to run neon on a mobile phone, offline?
- nikita 4y agoWe have some ideas of compiling Postgres to wasm and sync with the mothership in the cloud. But we haven’t funded the work. Check out electricsql they are looking at this problem.
- thruflo 4y agoHey, link for the curious: https://electric-sql.com https://electric-sql.com Hybrid serverless <> local-first is the future. Neon in the client would be so cool.
- vojtad 4y agoJust for the recerence, it is possible to use Cloudflare Tunnel to connect to Postgres from Cloudflare Workers [1]. IIRC they also use WebSockets for communication between the Worker and the Tunnel. [1] https://developers.cloudflare.com/workers/tutorials/query-postgres-from-workers-using-database-connectors/ https://developers.cloudflare.com/workers/tutorials/query-po...
- dboreham 4y agoHmm. Wouldn't this also be useful for browser-hosted application code that wants to talk to PG directly?
- kelvich 4y agoRight, that is one of the use cases. Auth is tricky part in that setup -- in the browser user may change the query in arbitrary way. But there are some workarounds like obtaining JWT from 3rd party service and checking it via Row-Level Security policy in Postgres.