Prisma Accelerate 的已知限制
以下是使用 Accelerate 时已知限制的描述。如果你遇到任何其他问题,请通过 Discord 与我们分享。
¥Below are descriptions of known limitations when using Accelerate. If you encounter any additional ones, please share them with us via Discord.
无法缓存原始查询
¥Cannot cache raw queries
目前,无法缓存 原始查询 的响应。
¥At the moment, it is not possible to cache the responses of raw queries.
与 Fluent API 不兼容
¥Not compatible with the fluent API
客户端扩展(在加速中使用)目前无法正确转发 流畅的 API 类型。我们希望尽快在客户端扩展中修复此问题。
¥Client Extensions (which are used in Accelerate) currently do not correctly forward the fluent API types. We hope to get a fix into Client Extensions soon.
与极其繁重或长时间运行的查询不兼容
¥Not compatible with extremely heavy or long-running queries
Accelerate 旨在支持高性能、低延迟查询。它不适用于可能导致性能问题或资源争用的极其繁重或长时间运行的查询。虽然限制是可配置的,但我们建议你优化查询,以确保它们符合建议的准则。
¥Accelerate is designed to work with high-performance, low-latency queries. It is not intended for use with extremely heavy or long-running queries that may cause performance issues or resource contention. While limits are configurable, we recommend optimizing your queries to ensure they fit within the recommended guidelines.
对于无法优化或精简的查询,我们推荐以下两种解决方案之一:
¥For queries that cannot be optimized or pared down, we recommend one of two solutions:
-
使用只读副本扩展:Prisma ORM 只读副本扩展 允许你设置两种不同的连接:一个
primary
和一个replica
。你可以将 Accelerate 连接设置为primary
,然后将直接连接设置为replica
。任何资源密集型或长时间运行的查询都可以路由到replica
,而primary
(你的 Accelerate 连接)将处理常规查询。请注意,此解决方案需要你设置直接连接,并且需要完整生成的 Prisma 客户端(即没有--no-engine
)。¥Use the read replica extension: The Prisma ORM read replica extension allows you to set up two different connections: a
primary
and areplica
. You can set up your Accelerate connection as theprimary
and then a direct connection as thereplica
. Any queries that are resource-intensive or long-running can then be routed to thereplica
, while theprimary
(your Accelerate connection) will handle normal queries. Please note that this solution requires you to both set up a direct connection and requires the full generated Prisma Client (i.e. without--no-engine
). -
单独的分析查询:我们推荐的解决方案是将你的分析查询分离到单独的应用中。然后,这个单独的应用可以使用直接连接,以便它可以运行繁重的查询,而不会影响由 Accelerate 驱动的应用的性能或成本。
¥Separate analytics queries: Our preferred solution is to separate your analytics queries into a separate application. This separate application can then use a direct connection so that it can run heavy queries without impacting the performance or cost of your Accelerate-powered application.
如果你的用例需要运行极其繁重或长时间运行的查询以及 Prisma Accelerate,请联系我们。
¥If you have a use case that requires running extremely heavy or long-running queries and Prisma Accelerate, please reach out to us.
与 MongoDB 连接字符串中的直接 IPv4 地址不兼容
¥Not compatible with direct IPv4 addresses in MongoDB connection strings
Accelerate 不支持 MongoDB 连接字符串中的直接 IPv4 地址。提供 IPv4 地址后,Accelerate 会将其转换为 IPv6 格式,以便通过其 NAT 网关进行路由。由于端口值的格式问题,此转换可能会导致连接字符串被视为无效。
¥Accelerate does not support direct IPv4 addresses in MongoDB connection strings. When an IPv4 address is provided, Accelerate converts it to an IPv6 format to route through its NAT gateway. This conversion may cause the connection string to be considered invalid due to the formatting of the port value.
解决方法:要解决此问题,请创建指向你的 IPv4 地址的 DNS 记录,并在连接字符串中使用该 DNS 记录,而不是直接使用 IP 地址。
¥Workaround: To resolve this issue, create a DNS record that points to your IPv4 address and use that DNS record in your connection string instead of the direct IP.
示例
¥Example
-
IPv4 连接字符串(不支持):
mongodb://user:password@192.168.1.100:27017/db_name
¥IPv4 connection string (not supported):
mongodb://user:password@192.168.1.100:27017/db_name
-
DNS 记录连接字符串(支持):
mongodb://user:password@my-database.example.com:27017/db_name
¥DNS record connection string (supported):
mongodb://user:password@my-database.example.com:27017/db_name
有关 Accelerate IPv6 优先设计的更多详细信息,请参阅我们的 博客文章。
¥For additional details on Accelerate’s IPv6-first design, refer to our blog post.