Snowpark Container Services¶
关于 Snowpark Container Services¶
Snowflake 首先提供 SQL 数据库,用于查询结构化和半结构化数据,但单独使用 SQL 并不适合复杂计算或机器学习。为解决这个问题,Snowflake 推出了 Snowpark,它允许开发者使用 Python、Java 和 Scala 等语言来构建数据应用程序和管道。Snowpark 将此代码转换为优化的 SQL,将现代语言的灵活性与 Snowflake SQL 引擎的性能和可扩展性相结合。
为获得更高的灵活性,Snowflake 提供 Snowpark Container Services,这是 Snowflake 中的一个托管容器编排平台。您可以将应用程序及其依赖项打包到 Open Container Initiative (OCI) 镜像,其中可以包含任何编程语言、框架或库。这使得需要自定义运行时、专用库或特定软件配置的用例成为可能。此外,还支持高级 CPUs 和 GPUs,您可以运行计算密集型工作负载,例如 ML 模型服务、ML 模型训练和高级 AI 分析。Snowflake 管理底层基础设施,但您可以完全控制容器化环境的内容。
As a fully managed service, Snowpark Container Services streamlines operational tasks related to running your containers. Using best practices, Snowpark Container Services handles the intricacies of container management, including security and configuration. This ensures that you can focus on developing and deploying your applications without the overhead of managing the underlying infrastructure.
Snowpark Container Services 与 Snowflake 完全集成。例如,应用程序可以轻松执行以下任务:
连接到 Snowflake 并在 Snowflake 虚拟仓库中运行 SQL。
访问 Snowflake 暂存区中的数据文件。
Process data retrieved through SQL queries.
您的应用程序可以利用现有的 Snowflake 配置,包括以下项目:
网络入口的网络策略
网络出口的外部访问集成
基于角色的访问控制,用于实现服务到服务的通信
日志、指标和事件的事件表
Snowpark Container Services is also integrated with third-party tools. It lets you use third-party clients, such as Docker, to easily upload your application images to Snowflake. Seamless integration makes it easier for teams to focus on building data applications.
All these capabilities come with Snowflake platform benefits, most notably ease-of-use, security, and governance features. You also get a scalable, flexible compute layer next to the powerful Snowflake data layer without needing to move data off the platform.
Common scenarios for using Snowpark Container Services¶
您的应用程序可以部署到 Snowflake 区域,而无需担心底层云平台(AWS、Azure 或 Google Cloud)。Snowpark Container Services 还使您的应用程序可以轻松访问 Snowflake 数据。此外,Snowflake 还管理底层计算节点。
以下列表显示了 Snowpark Container Services 的常见工作负载:
批量数据处理作业: 运行类似于存储过程的灵活作业,从 Snowflake 或外部源提取数据,对其进行处理并生成结果。工作负载可以分布在多个作业实例,并且图形处理单元 (GPU) 支持计算密集型任务,例如 AI 和机器学习。
服务函数: 您的服务可以提供服务函数,以便您的查询可以将批量数据发送到您的服务进行处理。查询处理在 Snowflake 的高级查询引擎中进行,您的服务提供自定义数据处理,Snowflake 可以将其扩展到多个计算节点。有关示例,请参阅 教程 1。在本教程的第 4 步中,您将在查询中调用服务函数。
通过 APIs 或 Web UI 访问 Snowflake 数据: 部署公开的服务 APIs 或具有嵌入式业务逻辑的 Web 界面。用户与服务交互,而不是与原始数据交互。调用方权限可确保查询以正确的用户权限运行。有关示例,请参阅 教程 1。在本教程中,该服务还公开了一个 Web UI 到互联网。在第 4 步中,从 Web 浏览器向服务发送请求。
它是如何工作的?¶
要在 Snowpark Container Services 中运行容器化的应用程序,除了使用基本 Snowflake 对象(如数据库和仓库)外,还可以使用以下对象:镜像仓库、计算池 和 服务。
Snowflake offers an OCIv2 (https://github.com/opencontainers/distribution-spec/blob/main/spec.md) compliant image registry service for storing your images. This service enables Open Container Initiative (OCI) clients, such as Docker CLI, to upload your application images to a repository (a storage unit) in your Snowflake account. You create a repository using the CREATE IMAGE REPOSITORY command. For more information, see Working with an image registry and repository.
After you upload your application image to a repository, you can run your application by creating a long-running service or executing a job service.
Service: A service is long-running and, as with a web service, you explicitly stop it when it is no longer needed. If a service container exits for whatever reason, Snowflake restarts that container. To create a service, such as a full stack web application, use the CREATE SERVICE command.
Job service: A job service has a finite lifespan, similar to a stored procedure. When all containers exit, the job service is done. Snowflake doesn't restart any job service containers. To start a job service, such as training a machine learning model with GPUs, use the EXECUTE JOB SERVICE command.
Your services, including job services, run in a compute pool, which is a collection of one or more virtual machine (VM) nodes. You first create a compute pool by using the CREATE COMPUTE POOL command, and then specify the compute pool when you create a service or a job service. The required information to create a compute pool includes the machine type, the minimum number of nodes to launch the compute pool with, and the maximum number of nodes the compute pool can scale to. Some of the supported machine types provide GPU. For more information, see Working with compute pools.
创建服务后,用于创建服务的同一 Snowflake 账户中的用户可以使用该服务,前提是他们具有适当的权限。有关更多信息,请参阅 使用服务。
备注
Snowpark Container Services 文档在概念解释和示例中主要使用 SQL 命令和函数。Snowflake 还提供其他接口,包括 Python APIs、REST APIs,以及用于大多数操作的 Snowflake CLI 命令行工具。
可用区域和注意事项¶
除以下地区外,所有 地区 均提供 Snowpark Container Services:
Snowpark Container Services 适用于 Google Cloud 商业区域中的账户,me-central2(中东中部 2(达曼))区域除外。
Snowpark Container Services 支持 AWS US 东部(商业政府 – 弗吉尼亚北部)地区的 公共部门(政府)工作负载,不适用于其他 AWS 或 Azure 政府区域。
Snowpark Container Services 不适用于试用账户,但运行笔记本除外。
下一步是什么?¶
如果您刚开始使用 Snowpark Container Services,我们建议您先浏览教程,然后继续学习其他主题,以了解更多信息并创建自己的容器化应用程序。以下主题提供了更多信息: