Skip to main content

部署 Prisma ORM

使用 Prisma Client 的项目可以部署到许多不同的云平台。鉴于云平台的多样性和不同的名称,值得注意的是不同的部署范例,因为它们会影响你使用 Prisma Client 部署应用的方式。

¥Projects using Prisma Client can be deployed to many different cloud platforms. Given the variety of cloud platforms and different names, it's noteworthy to mention the different deployment paradigms, as they affect the way you deploy an application using Prisma Client.

部署范例

¥Deployment paradigms

每种范例都有不同的权衡,这些权衡会影响应用的性能、可扩展性和运营成本。

¥Each paradigm has different tradeoffs that affect the performance, scalability, and operational costs of your application.

此外,应用的用户流量模式也是需要考虑的重要因素。例如,任何具有一致用户流量的应用可能更适合 持续运行范式,而具有突然峰值的应用可能更适合 serverless

¥Moreover, the user traffic pattern of your application is also an important factor to consider. For example, any application with consistent user traffic may be better suited for a continuously running paradigm, whereas an application with sudden spikes may be better suited to serverless.

传统服务器

¥Traditional servers

如果 Node.js 进程持续运行并同时处理多个请求,则你的应用是 传统部署。你的应用可以部署到平台即服务 (PaaS),如 Heroku科耶布Render;作为 Docker 容器部署到 Kubernetes;或作为虚拟机或裸机服务器上的 Node.js 进程。

¥Your application is traditionally deployed if a Node.js process is continuously running and handles multiple requests at the same time. Your application could be deployed to a Platform-as-a-Service (PaaS) like Heroku, Koyeb, or Render; as a Docker container to Kubernetes; or as a Node.js process on a virtual machine or bare metal server.

也可以看看:长时间运行的进程中的连接管理

¥See also: Connection management in long-running processes

无服务器函数

¥Serverless Functions

如果你的应用的 Node.js 进程(或其分解为函数的子集)在请求传入时启动,并且每个函数一次仅处理一个请求,则你的应用是 serverless。你的应用很可能会部署到功能即服务 (FaaS) 产品,例如 AWS LambdaAzure 函数

¥Your application is serverless if the Node.js processes of your application (or subsets of it broken into functions) are started as requests come in, and each function only handles one request at a time. Your application would most likely be deployed to a Function-as-a-Service (FaaS) offering, such as AWS Lambda or Azure Functions

无服务器环境具有热启动的概念,这意味着对于同一函数的后续调用,它可能会使用已分配的进程、内存、文件系统(/tmp 在 AWS Lambda 上可写)甚至数据库连接仍然可用的现有容器。

¥Serverless environments have the concept of warm starts, which means that for subsequent invocations of the same function, it may use an already existing container that has the allocated processes, memory, file system (/tmp is writable on AWS Lambda), and even DB connection still available.

通常,任何一段代码 在处理程序之外 都保持初始化状态。

¥Typically, any piece of code outside the handler remains initialized.

也可以看看:无服务器环境中的连接管理

¥See also: Connection management in serverless environments

边缘函数

¥Edge Functions

如果你的应用是 serverless 并且功能分布在靠近用户的一个或多个区域,那么你的应用就是 边缘部署

¥Your application is edge deployed if your application is serverless and the functions are distributed across one or more regions close to the user.

通常,边缘环境还具有与传统或无服务器环境不同的运行时,导致通用 API 不可用。

¥Typically, edge environments also have a different runtime than a traditional or serverless environment, leading to common APIs being unavailable.