If I open a web socket connection with one of my SageMaker's notebook cells how long will the connection last?

0

If I open a web socket connection with one of my SageMaker's notebook cells how long will the connection last?

I realise the time frame may not be exact and I cannot expect 100% uptime. It's more about whether there is a set cut off time i.e. every 24hrs the kernel shuts down or restarts.

A secondary question: What is the best way to deploy the notebook as a web service that maintains the web socket connection indefinitely?

질문됨 2년 전848회 조회
1개 답변
1

SageMaker has a few different notebook environments, so the answer might depend a bit:

  1. If you're using SageMaker Studio Lab - the new free notebook service not tied to an AWS Account - "sessions" are limited in duration and the environment will automatically shut down when your limit expires (currently 4hrs for GPU, 12hrs for CPU)
  2. In SageMaker Studio, your running kernel's lifespan is tied to the "app" (container) it runs in. If one user opens multiple notebooks on the same kernel type and instance type (e.g. commonly Python 3 (Data Science) and ml.t3.medium), then those notebooks will share a container. Your user's Jupyter server itself runs in a different container.
  3. In SageMaker Notebook Instances (NBIs), one "instance" runs both the Jupyter server and running notebook kernels (a bit more similar to using Jupyter on local machine).

In both Studio and NBIs (barring availability interruptions etc), there's usually no automatic restart of your kernels unless you explicitly set one up. Of course, stopping and re-starting your NBIs (and deleting/re-creating your Studio apps) regularly is a good practice - to consume security and functionality updates.

For example, I've observed notebooks in both Studio and NBIs successfully maintain their state for ~months without any intervention - so if your running kernel was keeping the websocket connection alive - it could persist. Anecdotally, I think I've also observed the kernel<->notebook UI connection being a bit more stable in Studio than NBIs occasionally... I guess because the more formal separation between kernel and notebook server in separate containers means Jupyter handles broken connections a bit more robustly?

Maybe the second part of your question is the more interesting one: As it sounds like what you're trying to isn't really a great fit for notebook environments anyway. I think the answer here will depend on what exactly you're trying to host/serve (e.g. a full Jupyter-like notebook experience; Just read-only view of the cell inputs and outputs; something different and more UI-like backed by notebook data; an ML model) so maybe worth raising as a separate question with a few more details?

Depending on what exactly the use case is, you might like to check out SageMaker model deployment, this blog and sample using Streamlit on AWS, or maybe something different.

AWS
전문가
Alex_T
답변함 2년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠