Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Large amounts of notebook servers 50+ causes jupyter webapp slowness. #7259

Closed
boarder7395 opened this issue Sep 1, 2023 · 3 comments
Closed

Comments

@boarder7395
Copy link
Contributor

The way the jupyter web app is loaded causes slowness when the there are a lot of notebooks in a single namespace.

The notebook_dict_from_k8s_obj function calls the kubernetes api for events on each notebook in the namespace. With 50 notebooks we're seeing around 1.8-2 second response time. This is really bogging down the UI.

Relevant Code:

@bp.route("/api/namespaces/<namespace>/notebooks")
def get_notebooks(namespace):
notebooks = api.list_notebooks(namespace)["items"]
contents = [utils.notebook_dict_from_k8s_obj(nb) for nb in notebooks]
return api.success_response("notebooks", contents)

def notebook_dict_from_k8s_obj(notebook):
cntr = notebook["spec"]["template"]["spec"]["containers"][0]
server_type = None
if notebook["metadata"].get("annotations"):
annotations = notebook["metadata"]["annotations"]
server_type = annotations.get("notebooks.kubeflow.org/server-type")
return {
"name": notebook["metadata"]["name"],
"namespace": notebook["metadata"]["namespace"],
"serverType": server_type,
"age": notebook["metadata"]["creationTimestamp"],
"last_activity": get_notebook_last_activity(notebook),
"image": cntr["image"],
"shortImage": cntr["image"].split("/")[-1],
"cpu": cntr["resources"]["requests"]["cpu"],
"gpus": process_gpus(cntr),
"memory": cntr["resources"]["requests"]["memory"],
"volumes": [v["name"] for v in cntr["volumeMounts"]],
"status": status.process_status(notebook),
"metadata": notebook["metadata"]
}

# Try to extract information about why the notebook is not starting
# from the notebook's events (see find_error_event)
notebook_events = get_notebook_events(notebook)
status_event, reason_event = get_status_from_events(notebook_events)

def get_notebook_events(notebook):
name = notebook["metadata"]["name"]
namespace = notebook["metadata"]["namespace"]
nb_creation_time = dt.datetime.strptime(
notebook["metadata"]["creationTimestamp"], "%Y-%m-%dT%H:%M:%SZ"
)
nb_events = api.list_notebook_events(name, namespace).items
# User can delete and then create a nb server with the same name
# Make sure previous events are not taken into account
nb_events = filter(
lambda e: event_timestamp(e) >= nb_creation_time, nb_events,
)
return nb_events

@kubeflow-bot kubeflow-bot added this to To Do in Needs Triage Sep 1, 2023
@boarder7395
Copy link
Contributor Author

Created PR #7260

@boarder7395
Copy link
Contributor Author

After doing additional testing I realized the primary problem was the read from disk for every request for every notebook. I expect the serialized API requests will also cause slowness but a better fix for that is true pagination.

@boarder7395
Copy link
Contributor Author

I took a look at the code and fixing that backend code to allow pagination should be pretty straightforward. I'd be happy to pick up that work.

Although I do not have experience with angular js for implementing the front end changes.

Needs Triage automation moved this from To Do to Closed Oct 4, 2023
@kubeflow-bot kubeflow-bot removed this from Closed in Needs Triage Oct 4, 2023
kimwnasptd pushed a commit to kimwnasptd/kubeflow that referenced this issue Oct 13, 2023
…ow#7259 (kubeflow#7260)

* Only load spawner_ui_config.yaml once every 10 minutes.

* Update cache to 60 seconds
google-oss-prow bot pushed a commit that referenced this issue Oct 13, 2023
…loses #7259 (#7340)

* Only load spawner_ui_config.yaml once every 10 minutes.

* Update cache to 60 seconds

Co-authored-by: boarder7395 <37314943+boarder7395@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant