比较 Accelerate
Prisma Accelerate 支持服务于全球受众的产品,其全局缓存系统和跨多个区域的连接池,无论你的用户(或数据库)位于世界何处,都能提供低延迟的一致数据访问。
¥Prisma Accelerate supports products that serve a global audience, with a global caching system and connection pool that spans multiple regions, providing consistent access to data with low latency no matter where your user (or your database) is located in the world.
托管连接池旨在支持无服务器基础架构,能够处理大量连接并轻松应对流量高峰。
¥The managed connection pool is designed to support serverless infrastructure, capable of handling high volumes of connections and adapting to traffic spikes with ease.
探索 Prisma Accelerate 与市场上其他全局缓存和连接池解决方案的比较,并发现其独特之处。
¥Explore how Prisma Accelerate compares to other global cache and connection pool solutions on the market, and discover what sets it apart.
Accelerate 的独特之处是什么?
¥What makes Accelerate unique?
Prisma Accelerate 之所以受到众多用户的青睐,有几个关键原因使其如此独特:
¥Prisma Accelerate is chosen and loved by many for a number of key reasons which make Accelerate unique:
-
查询级别策略:Accelerate 是唯一提供查询级缓存策略的解决方案,允许你针对每个查询控制具体的缓存策略。通常有些值需要长时间缓存,有些值需要短时间缓存,而有些值根本不应该缓存。使用 Accelerate,你可以做到这一点,甚至可以为每个查询设置不同的缓存策略。
¥Query-Level policies: Accelerate is the only solution that offers query-level cache policies, allowing you to control the cache strategy for each query specifically. It is common to have some values that need to be cached for a long time, others that need caching for a short time, and some that should not be cached at all. With Accelerate you can do this, and even set different cache strategies per query.
-
默认全局:Accelerate 默认全局分布。你无需担心用户相对于数据库的位置。
¥Global by default: Accelerate is globally distributed by default. You never need to worry about where a user is located with respect to your database location.
-
完全托管:你无需管理服务器或担心正常运行时间。Accelerate 完全为你托管。
¥Fully managed: You don't need to manage a server or worry about uptime. Accelerate is fully managed for you.
-
自动扩展:Accelerate 会自动调整资源以匹配工作负载需求,在流量高峰期间提供快速且稳定的性能。
¥Auto-scaling: Accelerate automatically adjusts resources to match workload demands, providing fast and consistent performance during traffic spikes.
Accelerate 全局缓存
¥Accelerate global cache
Prisma Accelerate 提供强大的全局缓存,因此无论你的数据库托管在何处,你都可以在边缘(距离用户最近的点)向用户提供数据。这不仅可以提升用户体验,还可以通过避免往返操作来减少数据库的读取负载。
¥Prisma Accelerate offers a powerful global cache, so you can serve data to your users at the edge — the closest point to where the users are located — no matter where your database is hosted. This not only speeds up the experience for users, but also reduces read load on your database as well by avoiding roundtrips.
加速 | 超级驱动器 | Planetscale Boost | |
---|---|---|---|
完全托管 | ✅ | ✅ | ✅ |
全球分布式边缘基础设施 | ✅ | ✅ | ✅ |
从代码中控制缓存策略 | ✅ | ❌ | ❌ |
查询级缓存策略 | ✅ | ❌ | ❌ |
使用 API 密钥进行身份验证 | ✅ | ❌ | ❌ |
与 Postgres 兼容 | ✅ | ✅ | ❌ |
兼容 MySQL | ✅ | ❌ | ✅ |
兼容 MongoDB | ✅ | ❌ | ❌ |
自动缓存更新 | ❌ | ❌ | ✅ |
为什么这些命令很重要?
¥Why are these important?
-
由于 Accelerate 扩展了 Prisma 客户端,你只需额外添加一行代码即可直接从代码库控制缓存策略。集成无缝。以下是使用 重新验证时过期的缓存策略 的示例:
¥Since Accelerate extends the Prisma client, you can control caching policies directly from your codebase with just an extra line of code. Integration is seamless. Here is an example using the stale-while-revalidating caching strategy:
await prisma.user.findMany({
cacheStrategy: {
swr: 60,
},
}); -
查询级缓存策略对于重要的应用至关重要,这样你就可以控制哪些查询需要缓存以及策略的特性。你可能希望应用中的某些数据缓存几天,其他数据缓存几分钟,而其他数据则根本不缓存。这只有使用 Prisma Accelerate 才能实现。
¥Query level cache policies are critical for serious applications, so that you can control which queries are cached, and the characteristics of the policy. You may want certain data in your app to be cached for several days, other data to be cached for a just a few minutes, and other data to be not cached at all. This is only possible with Prisma Accelerate.
-
使用 API 密钥进行身份验证是一项非常有用的安全措施,可让你将数据库凭据与应用密钥分离。你可以根据需要轻松轮换 API 密钥,而无需更改数据库中的任何凭据
¥Authenticating with an API key can be a helpful security measure, allowing you to decouple database credentials from application secrets. Easily rotate API keys as often as you like, without needing any credential changes in your database
-
自动缓存更新意味着当数据库发生更改时,缓存会自动更新。使用 Accelerate,你可以使用 各种缓存策略 控制缓存的失效方式。
¥Automatic cache updates means that the cache is automatically updated when a change in the database occurs. With Accelerate, you are in control of how the cache is invalidated, using various caching strategies.
Accelerate 连接池
¥Accelerate connection pool
Prisma Accelerate 包含一个全局托管的连接池,可让你轻松处理峰值负载。使用连接池非常重要,尤其是对于无服务器基础架构而言,因为无服务器基础架构本质上无法自行控制与数据库的连接量。Prisma Accelerate 提供完全托管的全球托管选项,可自动扩展以支持任何工作负载。
¥Prisma Accelerate includes a globally hosted connection pooler, which allows you to handle peak loads without any problem. Using a connection pool is important especially for serverless infrastructure, which by nature is not able to control connection volume to the database on its own. Prisma Accelerate offers a fully managed, globally colocated option, which auto scales to support any workload.
管理
¥Management
加速 | pgbouncer | pgcat | Digital Ocean (pgbouncer) | Neon (pgbouncer) | Supavisor | 超级驱动器 | |
---|---|---|---|---|---|---|---|
完全托管 | ✅ | ❌ | ❌ | 🟠 | ✅ | ❌ | ✅ |
全球分布式 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
已与 ORM 客户端集成 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
使用 API 密钥进行身份验证 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
冗余 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
为什么这些命令很重要?
¥Why are these important?
-
如果你决定自行管理连接池(例如使用 pgbouncer 或 pgcat),你还将负责管理其正常运行时间。如果服务器崩溃,你的应用可能会处于宕机状态,直到你恢复它为止。Accelerate 作为一个完全托管的解决方案,即使出现任何基础设施问题(这种情况不太可能发生),也能以透明的方式为你恢复缓存。
¥If you decide to manage a connection pooler yourself (eg. using pgbouncer or pgcat) you will also be responsible for managing its uptime. If the server crashes, your application may be down until you recover it. Accelerate, as a fully managed solution will be recovered for you transparently, in the unlikely case of any infrastructure issue.
-
Digital Ocean 上托管的 pgbouncer 选项是半托管的,你需要在 Digital Ocean 账户中进行设置,并确保其始终平稳运行。
¥The hosted pgbouncer option on Digital Ocean is semi-managed, you will need to set it up in your Digital Ocean account, and ensure it is running smoothly at all times.
-
使用 API 密钥进行身份验证是一项非常有用的安全措施,可让你将数据库凭据与应用密钥分离。你可以根据需要轻松轮换 API 密钥,而无需更改数据库中的任何凭据
¥Authenticating with an API key can be a helpful security measure, allowing you to decouple database credentials from application secrets. Easily rotate API keys as often as you like, without needing any credential changes in your database
-
在连接池服务发生故障(这种情况不太可能发生)的情况下,冗余非常有用。使用 Accelerate,查询会自动无缝地移交给另一台服务器,并在不中断的情况下恢复。
¥Redundancy is helpful in the unlikely scenario that your connection pool service goes down. With Accelerate, it is automatically and seamlessly handed over to another server and recovered without any interruption.
表现
¥Performance
加速 | pgbouncer | pgcat | Digital Ocean (pgbouncer) | Neon (pgbouncer) | Supavisor | 超级驱动器 | |
---|---|---|---|---|---|---|---|
自动扩展 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
全球分布式 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
通过 HTTP 优化的查询 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ✅ |
隔离计算 | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
为什么这些命令很重要?
¥Why are these important?
-
Accelerate 会根据你的应用工作负载自动扩展和缩减,这意味着你永远不会耗尽计算资源。此外,这提供了重要的冗余,以防止任何单个计算实例发生故障 - 如果某个实例发生故障(这种情况不太可能发生),Accelerate 将自动生成一个新实例。
¥Accelerate will automatically scale up and down to suit your application workload, meaning you'll never run out of compute resource. Additionally, this provides important redundancy to protect against any single compute instance failing — in the unlikely event of an instance going down, Accelerate will automatically spawn a new instance.
-
应用服务器与 PgBouncer 或数据库之间的跨区域 TCP 握手成本高昂且耗时。如果仅在 PgBouncer 层重用连接,TCP 握手和连接建立仍然会在每个请求上消耗不必要的时间,从而降低连接重用的效率。Prisma Accelerate 通过利用 HTTP 改进了这一点,从而更高效地进行连接管理。它减少了与 TCP 握手相关的开销,从而使应用和数据库之间的交互更快、响应更快。
¥Cross-region TCP handshakes between the application server and PgBouncer or the database are costly and time-consuming. If connections are reused only at the PgBouncer layer, the TCP handshake and connection setup still consume unnecessary time on every single request, which undermines the efficiency of connection reuse. Prisma Accelerate improves this by leveraging HTTP, which is more efficient for connection management. It reduces the overhead associated with TCP handshakes, resulting in faster, more responsive interactions between your application and the database.
-
无需担心 '嘈杂邻居' 的计算资源隔离问题。其他客户不会影响你自己的性能。
¥Never worry about 'noisy neighbors' with isolated compute resources. Other customers never impact on your own performance.
数据库支持
¥Database Support
加速 | pgbouncer | pgcat | Digital Ocean (pgbouncer) | Neon (pgbouncer) | Supavisor | 超级驱动器 | |
---|---|---|---|---|---|---|---|
PostgreSQL | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ |
MySQL | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
Planetscale | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
CockroachDB | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
MongoDB | ✅ | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |