创建

登录 ReadmeX

或

了解我们如何处理你的信息: 隐私政策

ReadmeX

陪你读懂 AI 动态

今天,想先了解什么?

选一份动态总结,或直接聊聊你的问题。

社区和关注动态总结只属于你自己。

资讯

Modal 发布 Sticky Sessions 会话粘性路由

AI 总结

Modal 宣布推出 Sticky Sessions,这一构建在 Modal Servers 之上的路由功能会把同一会话内的每个请求都发送到同一个容器。开发者通过 @modal.sessioned() 装饰器启用,并用 SDK 或 HTTP API 启动会话,每个会话会获得签名令牌,便于多个客户端共享同一状态。Modal 表示会话由此成为自动扩缩容的单位,并列出语音智能体、共享聊天室、Gradio 与 Streamlit 等有状态界面以及多人游戏作为适用场景。

深度见解

Modal 在博客中称,流式语音转文字、语音智能体等有状态 AI 工作负载需要会话粘性,而其原有的请求级路由无法提供,这一功能正是为此推出。

At Modal, our serverless compute powers real-time inference, training, and batch jobs, scaling automatically with demand. Sandboxes offer a different model, containers whose lifecycles you explicitly control. A growing number of workloads require something in-between; autoscaling serverless compute that maintains continuity between requests. Consider a speech-to-text model with decoder state for an audio stream, a voice agent that holds a conversation, or a multiplayer game. For these workloads, users must come back to the same container on every reconnect for the entirety of their session.

We recently launched Sticky Sessions, built on top of our low-latency Modal Servers. Every session’s requests land on the same container. To use Sticky Sessions, just create a Modal Server with the @modal.sessioned() decorator and start the sessions with the SDK or the HTTP API:

@app.server()
@modal.sessioned()
class Server:
    @modal.enter()
    def start(self):
	      subprocess.Popen(["python", "-m", "http.server", "8000"])

@app.local_entrypoint()
def main():
    session = Server.sessions.start(idle_timeout=600)
    headers = {"Modal-Authorization": f"Bearer {session.token}"}
    print(requests.get(Server.get_url(), headers=headers).text)

#Modal#Modal Servers#Sticky Sessions#Gradio#Streamlit#Pipecat

原文约 5 分钟读完阅读原文
群聊

还没有评论,来说说你的看法。