I have two virtual machines, call them A and B.
Both images have Ubuntu 18.04 with kernel 4.15.0-66-generic #75-Ubuntu SMP, x64 arch, 1 core Intel(R) Xeon(R) CPU E5-2660 v2 @ 2.20GHz; A has 2 GB memory while B has 4 GB memory. All updates have been installed. Both vm on the same virtualization infrastructure.
Notable services running on both: sshd, postgresql.
On vm B, an Oracle 12 RDBMS was previously installed and then removed (some system parameters were modified, I have made a diff of /sbin/sysctl -a ).
Both virtual machines have been upgraded from Ubuntu 16.04 to Ubuntu 18.04.
The issue is the following:
I have an extremely simple Django 2 web application (code below), using python 3.7 inside virtualenv; the web app does nothing, except running the embedded web server listening on localhost.
- on vm A, the web application executes with 0% CPU usage
- on VM B, the same web application consumes costantly between 10% and 20% of CPU on vm B. (All the other processes consume apparently 0% CPU). I am using top and htop.
I have used cProfile to profile the python web app on both virtual machines: the result is that, in both cases, nearly all (> 99%) the cpu time is spent on waitpid system call (according to "tottime" value reported by cProfile).
Regarding the diff of /bin/sysctl -a, these are the differences which might (or might be not) of interest:
- fs.aio-max-nr = 1048576
- fs.epoll.max_user_watches = 814612
- fs.file-max = 6815744
- kernel.shmall = 2097152
- kernel.shmmax = 8589934592
- kernel.threads-max = 31074
Any ideas? Hints? Is there an issue with Linux configuration (due to Oracle requirements)? Is there an issue with Python interpreter? Am I looking in the wrong place?
I know that I can destroy and regenerate vm B, but I would like to understand what is going on, it is an interesting technical issue.
The extremely simple Django web application was generated using these commands:
source venv/bin/activate # venv is a python 3.7.5 virtualenv with Django package mkdir test cd test django-admin startproject mysite cd mysite python manage.py runserver