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?

asked 2 years ago838 views
1 Answer
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
EXPERT
Alex_T
answered 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions