skip to Main Content

I have a server where my students should upload their web-applications (Python+Flask). The apps require resources only when they are used (when users enter the app), which is quite rare. I would like to share the server resources (memory and CPU) among the apps in the following way:

  • If only one app is currently used, then it should be allowed to use all the system resources.
  • If two or more apps are used, then the resources should be divided between them equally. For example, suppose the server has 4 GB memory and 2 CPUs, and two apps are used simultaneously. Then each app should be able to use at most 2 GB memory and 1 CPU.
  • In addition, I would like to give higher priority to some apps, such that, if a prioritized app is used, it can use as much memory+CPU as it needs, regardless of what other apps are used.

How can I do this?

Note: my server currently runs Ubuntu, but I can probably switch to another OS if needed.

2

Answers


  1. To deal with management across various operating systems, I recommend adopting a container-based approach, such as Docker, combined with an orchestrator like Kubernetes. This combination provides a more robust layer of control over the resources of each application.

    By utilizing Kubernetes to orchestrate and supervise the containers, you gain the ability to create isolated units, known as "pods," for each instance of the Flask application. This architecture allows you to define resource limits, such as memory and CPU, for each pod, ensuring efficient and fair allocation of machine resources. Additionally, you can create priority classes to differentiate applications that require higher resources, ensuring their needs are met when necessary.

    Login or Signup to reply.
  2. The task is a bit complicated if you only want to do it in a single server. There are many unanswered questions as to what you will do if someone wants to start an app and a different app is already running. Since only one app was running in the beginning, you have already allocated all the resources to the first app. Do you want to stop the currently running app and restart it so that the resource allocation is distributed?

    If you are open to it, I would recommend a cloud solution as it much more friendly and scalable. I am familiar with AWS so I will use it as an example but you are free to try other solutions.

    You can allocate each student with an EC2 instance and set the instance to stop on 10 mins or so of inactivity. This way you don’t need to worry about the resource allocation.

    I’m sorry if this is not what you were looking for.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search