某人
Neki – Sharded Postgres

原始链接: https://planetscale.com/blog/introducing-neki

PlanetScale 推出了全新的 PostgreSQL 扩展平台 **Neki**,目前已开放预览。Neki 旨在解决单实例 Postgres 的局限性,通过处理真空清理(vacuuming)、连接限制和维护窗口等常见的扩展瓶颈,且无需进行应用层分片,同时保持了与 Postgres 的完全兼容。 得益于该公司在管理大规模 MySQL 集群方面的八年经验,Neki 在每个分片上都运行真实的 PostgreSQL。其架构包含四个主要组件: * **路由器(Routers):** 处理分布式查询规划与路由。 * **分片组(Shard Groups):** 支持将工作负载扩展至多个真实的 Postgres 实例。 * **连接池(Connection Pooling):** 通过 Sidecar 优化以提升性能。 * **控制平面(Control Plane):** 管理模式变更、重新分片和升级的自动化工作流,确保零停机。 Neki 集成了分支(branching)和模式洞察(schema insights)等 PlanetScale 的常用功能。用户起初可将其作为单主实例使用,随后根据需求进行横向扩展。尽管 Neki 目前处于预览阶段,不建议用于生产环境,但用户可通过 PlanetScale 控制面板申请试用,以探索其架构与功能。

PlanetScale 最近发布了 **Neki**,这是一款专为处理大规模数据库负载而设计的分片 PostgreSQL 解决方案。 这一公告在 Hacker News 上引发了热烈讨论,主要集中在以下三个方面: * **沟通缺失:** 许多用户批评最初的发布博文未能清晰解释 Neki 的本质。社区对关键细节被掩盖或缺失表示不满,尽管 PlanetScale 在收到反馈后更新了博文。 * **开源担忧:** Neki 目前是专有软件,这令那些期望它是开源工具的用户感到失望,尤其是考虑到 PlanetScale 在开源 Vitess 项目上的历史背景。公司领导层则为闭源模式辩护,称这是对抗 AWS 等大型云服务商的竞争必要手段。 * **技术审查:** 技术讨论主要集中在一致性保证、跨分片操作的查询处理,以及 Neki 与 Citus 和 Multigres 等现有工具的对比。 此外,讨论中还出现了关于 PlanetScale 首席执行官 Sam Lambert 沟通风格的争议。他对比特竞争对手的激进态度引发了截然不同的反应:一些人认为这是不专业的“兄弟会”式行为,而另一些人则欣赏他的透明度和好战风格。
相关文章

原文

Neki is now available in platform preview.

Neki is built from lessons we’ve learned over eight years of running some of the largest sharded MySQL clusters in the world. Thousands of production workloads with millions of queries per second for companies where even a few seconds of downtime is a very public event. We know what it means to power the world’s biggest tier 0 workloads.

When we released PlanetScale Postgres a year and a half ago, we knew we needed to do more. In that time we’ve onboarded several thousands of customers on PlanetScale, some of them rivaling the size of our largest MySQL customers. Time and time again, we watched teams approach the ceiling of a single machine with Postgres. Metal bought them time, but with customers hitting the upper limit of what a single machine is capable of, we found there was no good option to hand them. Enter Neki.

You already know the problems that come with fast-growing Postgres databases: tables too large to vacuum or index without affecting traffic, backups taking hours, connection limits, maintenance windows for schema changes, transaction wraparound and so much more.

You can move to a bigger instance, but eventually you run out of big enough machines, and the problems don’t scale linearly as you add more cores and IOPS.

The existing answers each ask you to give something up. Application-level sharding pushes routing into your code. Postgres-”compatible” distributed databases hide the shard key from you, take away your extensions, and add complexity and latency which becomes difficult to handle and debug.

So we built Neki with a few principles, the biggest one being: stick to Postgres, don’t work around it, fake it, or turn away from it.

We architected Neki from first principles for Postgres, with real Postgres on every shard. There are four moving parts.

Neki routers

Your application first connects to a Neki router. The router speaks the Postgres wire protocol so your existing drivers and ORMs keep working with a single connection string. A router has a full Postgres query parser, a distributed query planner, query buffering and more. It parses your query, builds a plan that decides which shards should run it, sends the work out, and combines the results back into one stream. Routers can scale vertically and horizontally, so no single router becomes the bottleneck.

Sharding and shard groups

Every shard in Neki is real Postgres with 1 primary and at least 2 replicas, spread across availability zones. There is no modified storage engine. Extensions, SQL support, and performance behave the way Postgres behaves, because it is Postgres.

Shards are organized into shard groups, so different tables or workloads can live on different sets of shards. Each shard uses a configuration profile that defines its instance size, replica count, storage, Postgres parameters, and extensions, so you can size each group for its own traffic.

Connection pooling

Sidecars run alongside every Postgres instance. This is the piece that makes Neki's connection handling meaningfully better than just sticking PgBouncer in front of a database. Because Neki controls both ends of the connection, the router side and the Postgres side, it can size pools to what each instance can actually serve instead of estimating from outside the process.

Control plane

The control plane tracks the health of every node, runs planned switchovers and unplanned failovers, and coordinates the workflows that reshard data, apply schema changes, and perform version upgrades.

Data topology

Tying it together is the data topology, a JSON configuration that maps your logical tables onto physical shards. You define shard indexes, which specify the column Neki routes on and how that value gets hashed, and shard groups, which control how many shards a set of tables spreads across and which shards those are. Routers cache the topology and consult it on every plan.

Everything you would normally schedule a maintenance window for runs as a built-in workflow in Neki. Workflows provision new target nodes, catch them up with replication, switch traffic with a __neki metafunction, and retire the old nodes. All through the same psql connection your application uses.

This online operations model covers schema changes, version upgrades, planned and unplanned failovers, imports, and resharding.

Neki also includes all of the features you’ve come to rely on with PlanetScale: Insights, schema recommendations, branching, MCP, and more.

You can also run Neki unsharded, as a single primary with replicas. You get the improved connection pooling, online DDL, zero downtime upgrades, and health monitoring before you need to shard. When you do, resharding is a workflow you run against the cluster you already have.

We wanted to get Neki into your hands as soon as possible. You should not run production workloads on Neki during the platform preview. The product is still changing, and some of those changes will be breaking.

If you have any feedback, questions, or face any issues during the platform preview, please let us know. Fill out a support ticket or join our Discord

Sign in to PlanetScale, opt in to the platform preview, and create a Neki cluster. Read the Neki docs for more information about Neki's architecture, how to shard, and more.

If you have a large Postgres cluster and are curious whether Neki is a good fit, get in touch. We would love to do a private demo for your team, dig into your schema and query patterns, and give you real suggestions on how to shard.

联系我们 contact @ memedata.com