Serving Jupyter Notebooks to Thousands of Users

In our organization, Colaberry Inc, we provide professionals from various backgrounds and various levels of experience, with the platform and the opportunity to learn Data Analytics and Data Science. In order to teach Data Science, the Jupyter Notebook platform is one of the most important tools. A Jupyter Notebook is a document within an open-source web application that allows you to create and share documents that contain live code, equations, visualizations, and narrative text.

In this blog, we will learn the basic architecture of JupyterHub, the multi-user jupyter notebook platform, its working mechanism, and finally how to set up jupyter notebooks to serve a large user base.

Why Jupyter Notebooks?

In our platform, refactored.ai we provide users an opportunity to learn Data Science and AI by providing courses and lessons on Data Science and machine learning algorithms, the basics of the python programming language, and topics such as data handling and data manipulation.

Our approach to teaching these topics is to provide an option to “Learn by doing”. In order to provide practical hands-on learning, the content is delivered using the Jupyter Notebooks technology.

Jupyter notebooks allow users to combine code, text, images, and videos in a single document. This also makes it easy for students to share their work with peers and instructors. Jupyter notebook also gives users access to computational environments and resources without burdening the users with installation and maintenance tasks.

Limitations

One of the limitations of the Jupyter Notebook server is that it is a single-user environment. When you are teaching a group of students learning data science, the basic Jupyter Notebook server falls short of serving all the users.

JupyterHub comes to our rescue when it comes to serving multiple users, with their own separate Jupyter Notebook servers seamlessly. This makes JupyterHub equivalent to a web application that could be integrated into any web-based platform, unlike the regular jupyter notebooks.

JupyterHub Architecture

The below diagram is a visual explanation of the various components of the JupyterHub platform. In the subsequent sections, we shall see what each component is and how the various components work together to serve multiple users with jupyter notebooks.

Components of JupyterHub

Notebooks

At the core of this platform are the Jupyter Notebooks. These are live documents that contain user code, write-up or documentation, and results of code execution in a single document. The contents of the notebook are rendered in the browser directly. They come with a file extension .ipynb. The figure below depicts how a jupyter notebook looks:

 

Notebook Server

As mentioned above, the notebook servers serve jupyter notebooks as .ipynb files. The browser loads the notebooks and then interacts with the notebook server via sockets. The code in the notebook is executed in the notebook server. These are single-user servers by design.

Hub

Hub is the architecture that supports serving jupyter notebooks to multiple users. In order to support multiple users, the Hub uses several components such as Authenticator, User Database, and Spawner.

Authenticator

This component is responsible for authenticating the user via one of the several authentication mechanisms. It supports OAuth, GitHub, and Google to name a few of the several available options. This component is responsible for providing an Auth Token after the user is successfully authenticated. This token is used to provide access for the corresponding user.

Refer to JupyterHub documentation for an exhaustive list of options. One of the notable options is using an identity aggregator platform such as Auth0 that supports several other options.

User Database

Internally, Jupyter Hub uses a user database to store the user information to spawn separate user pods for the logged-in user and then serve notebooks contained within the user pods for individual users.

Spawner

A spawner is a worker component that creates individual servers or user pods for each user allowed to access JupyterHub. This mechanism ensures multiple users are served simultaneously. It is to be noted that there is a predefined limitation on the number of the simultaneous first-time spawn of user pods, which is roughly about 80 simultaneous users. However, this does not impact the regular usage of the individual servers after initial user pod creation.

How It All Works Together

The mechanism used by JupyterHub to authenticate multiple users and provide them with their own Jupyter Notebook servers is described below.

The user requests access to the Jupyter notebook via the JupyterHub (JH) server.
The JupyterHub then authenticates the user using one of the configured authentication mechanisms such as OAuth. This returns an auth token to the user to access the user pod.
A separate Jupyter Notebook server is created and the user is provided access to it.
The requested notebook in that server is returned to the user in the browser.
The user then writes code (or documentation text) in the notebook.
The code is then executed in the notebook server and the response is returned to the user’s browser.

Deployment and Scalability

The JupyterHub servers could be deployed in two different approaches:
Deployed on the cloud platforms such as AWS or Google Cloud platform. This uses Docker and Kubernetes clusters in order to scale the servers to support thousands of users.
A lightweight deployment on a single virtual instance to support a small set of users.

Scalability

In order to support a few thousand users and more, we use the Kubernetes cluster deployment on the Google Cloud platform. Alternatively, this could also have been done on the Amazon AWS platform to support a similar number of users.

This uses a Hub instance and multiple user instances each of which is known as a pod. (Refer to the architecture diagram above). This deployment architecture scales well to support a few thousand users seamlessly.

To learn more about how to set up your own JupyterHub instance, refer to the Zero to JupyterHub documentation.

Conclusion

JupyterHub is a scalable architecture of Jupyter Notebook servers that supports thousands of users in a maintainable cluster environment on popular cloud platforms.

This architecture suits several use cases with thousands of users and a large number of simultaneous users, for example, an online Data Science learning platform such as refactored.ai

48 Replies to “Serving Jupyter Notebooks to Thousands of Users”

  1. Greetings! Quick question that’s completely off topic. Do yoou know how to make your site mobile friendly?
    My blopg looks weird when broesing from my iphone4. I’m trying to find a template or plugin that
    might be able to fix this problem. If you have any suggestions, please share.
    Appreciate it! http://Boyarka-inform.com/

  2. You carry an extraordinary ability. Your posting skills are really superb. All the bests for submitting content over the internet and informing your audiences.

  3. I am curious to find out what blog system you happen to be using?I’m experiencing some minor security issues with my latest blog and I would like to find something moresafeguarded. Do you have any suggestions?

  4. A fascinating discussion is definitely worth comment. I do think that you need to write more about this subject matter, it may not be a taboo subject but usually people do not speak about such subjects. To the next! All the best!!

  5. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get four emails with the same comment. Is there any way you can remove me from that service? Bless you!

  6. Heya i am for the primary time here. I found this board and I in finding It really useful & it helped me out a lot.I am hoping to provide one thing again and aid others like you aided me.

  7. I like what you guys are usually up too. This sort of clever work and reporting! Keep up the fantastic works guys I’ve included you guys to blogroll.

  8. Sound Effects says:Thanks for sharing, this is a fantastic blog article.Really looking forward to read more. Really Great.Reply 10/28/2021 at 11:11 am

  9. Hello! I’m at work surfing around your blog from my new iphone!Just wanted to say I love reading your blog and look forward to all your posts!Carry on the outstanding work!

  10. Hello there! I just want to give you a big thumbs up for the great info you have got here on this post. I will be returning to your blog for more soon.

  11. Thank you for sharing your thoughts. I truly appreciate yourefforts and I am waiting for your next write ups thanks once again.

  12. Have you ever thought about including a little bit more than just your articles? I mean, what you say is important and everything. However just imagine if you added some great pictures or video clips to give your posts more, “pop”! Your content is excellent but with pics and video clips, this website could definitely be one of the greatest in its niche. Excellent blog!

  13. hey there and thank you for your information – I have certainly picked up something new from right here. I did however expertise several technical issues using this site, since I experienced to reload the website many times previous to I could get it to load properly. I had been wondering if your web host is OK? Not that I am complaining, but sluggish loading instances times will often affect your placement in google and can damage your high quality score if advertising and marketing with Adwords. Well I am adding this RSS to my e-mail and could look out for a lot more of your respective exciting content. Make sure you update this again soon..

  14. Thank you a lot for giving everyone an exceptionally brilliant chance to read critical reviews from this web site. It really is so lovely and full of a great time for me and my office fellow workers to visit your website at the least 3 times a week to read the fresh things you will have. And definitely, we are usually satisfied with all the beautiful suggestions you give. Selected 3 areas on this page are honestly the most efficient we have ever had.

  15. We absolutely love your blog and find a lot of your post’s to be just what I’m looking for. can you offer guest writers to write content for you personally? I wouldn’t mind producing a post or elaborating on some of the subjects you write about here. Again, awesome web site!

  16. Heya i am for the first time here. I found this board and I find It truly helpful & it helped me out much. I’m hoping to present something back and aid others like you helped me.

  17. Hi there! This post could not be written any better! Reading this post reminds me of my previous room mate! He always kept talking about this. I will forward this article to him. Fairly certain he will have a good read. Thank you for sharing!

  18. Hey just wanted to give you a brief heads up and let you know a few of the pictures aren’t loading properly. I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both show the same results.

  19. I would like to thnkx for the efforts you’ve put in writing this website. I’m hoping the same high-grade website post from you in the upcoming also. In fact your creative writing skills has encouraged me to get my own blog now. Actually the blogging is spreading its wings fast. Your write up is a good example of it.

  20. Its such as you read my thoughts! You seem to understand so much approximately this, like you wrote the ebook in it or something. I feel that you just could do with some percent to drive the message house a little bit, however instead of that, that is wonderful blog. A great read. I’ll certainly be back.

  21. Howdy very cool site!! Man .. Beautiful .. Wonderful .. I’ll bookmark your blog and take the feeds also…I’m glad to find numerous helpful info here in the post, we’d like develop extra strategies on this regard, thanks for sharing. . . . . .

  22. Hi, i feel that i saw you visited my web site so i came to “go back the favor”.I am attempting to in finding things to enhance my web site!I suppose its good enough to make use of some of your ideas!!

  23. One other issue is when you are in a scenario where you do not possess a cosigner then you may really want to try to wear out all of your financial aid options. You can get many grants and other grants that will give you funds to help with education expenses. Many thanks for the post.

  24. The following time I learn a blog, I hope that it doesnt disappoint me as much as this one. I mean, I do know it was my option to learn, however I really thought youd have something interesting to say. All I hear is a bunch of whining about something that you could repair when you werent too busy on the lookout for attention.

  25. Aw, this was a very nice post. Spending some time and actual effort to create a very good article… but what can I say… I put things off a whole lot and don’t seem to get anything done.

  26. Hello there, just became aware of your blog through Google, and found that it’s really informative. I am gonna watch out for brussels. I’ll appreciate if you continue this in future. Many people will be benefited from your writing. Cheers!

Leave a Reply

Your email address will not be published. Required fields are marked *