<p dir="auto"><strong>Apache Airflow version</strong>: 1.10.9</p>
<p dir="auto">**Kubernetes version: 1.15.11</p>
<p dir="auto"><strong>Environment</strong>:</p>
<ul dir="auto">
<li><strong>Cloud provider</strong>: Google Cloud</li>
</ul>
<p dir="auto"><strong>What happened</strong>:</p>
<p dir="auto">I started to notice that Airflow webserver performance degrades over time. At one moment all my webserver pods had 100% CPU used, so UI and API became too slow, even unusable.<br>
I started to investigate this issue and looks like it depends on amount of task instances stored in DB. I had 100,000+ of them in the task_instance table. When I checked what process took full CPU on webserver pods, that was a gunicorn. After I cleaned up task_instance table, CPU usage dropped to nothing. Right now I have 30,000 tasks completed and see CPU spikes again.<br>
<a target="_blank" rel="noopener noreferrer nofollow" href="https://user-images.githubusercontent.com/57914365/81267874-d777f300-904f-11ea-9edf-3a389e5742e3.png"><img src="https://user-images.githubusercontent.com/57914365/81267874-d777f300-904f-11ea-9edf-3a389e5742e3.png" alt="Screenshot from 2020-05-07 10-43-27" style="max-width: 100%;"></a><br>
Also this issue seems to go away if I disable all my DAGs. Looks like webserver has some query which executes from time to time and consumes all the CPU.</p>
<p dir="auto"><strong>What you expected to happen</strong>:</p>
<p dir="auto">Amount of completed tasks do not influence the webserver performance.</p>
<p dir="auto"><strong>How to reproduce it</strong>:</p>
<p dir="auto">Generate 100,000 tasks and have 10 enabled DAGs in Airflow. Webserver CPU usage will be high, web becomes unusable.</p>
<p dir="auto"><strong>Apache Airflow version</strong>: 1.10.7</p>
<p dir="auto"><strong>Kubernetes version (if you are using kubernetes)</strong> (use <code class="notranslate">kubectl version</code>):</p>
<p dir="auto"><strong>Environment</strong>: local</p>
<ul dir="auto">
<li><strong>Cloud provider or hardware configuration</strong>: 3Ghz Intel Core i5, 16GB</li>
<li><strong>OS</strong> (e.g. from /etc/os-release): Debian 9</li>
<li><strong>Kernel</strong> (e.g. <code class="notranslate">uname -a</code>): Linux debian 4.9.0-12-amd64 <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="69689814" data-permission-text="Title is private" data-url="https://github.com/apache/airflow/issues/1" data-hovercard-type="pull_request" data-hovercard-url="/apache/airflow/pull/1/hovercard" href="https://github.com/apache/airflow/pull/1">#1</a> SMP Debian 4.9.210-1 (2020-01-20) x86_64 GNU/Linux</li>
<li><strong>Install tools</strong>:</li>
<li><strong>Others</strong>:</li>
</ul>
<p dir="auto"><strong>What happened</strong>:</p>
<p dir="auto">Traceback (most recent call last):<br>
File "/usr/local/bin/airflow", line 26, in <br>
from airflow.bin.cli import CLIFactory<br>
File "/usr/local/lib/python3.6/site-packages/airflow/bin/cli.py", line 71, in <br>
from airflow.www_rbac.app import cached_app as cached_app_rbac<br>
File "/usr/local/lib/python3.6/site-packages/airflow/www_rbac/app.py", line 26, in <br>
from flask_appbuilder import AppBuilder, SQLA<br>
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/<strong>init</strong>.py", line 6, in <br>
from .base import AppBuilder  # noqa: F401<br>
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/base.py", line 8, in <br>
from .api.manager import OpenApiManager<br>
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/api/manager.py", line 7, in <br>
from flask_appbuilder.baseviews import BaseView<br>
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/baseviews.py", line 21, in <br>
from .forms import GeneralModelConverter<br>
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/forms.py", line 17, in <br>
from .fieldwidgets import (<br>
File "/usr/local/lib/python3.6/site-packages/flask_appbuilder/fieldwidgets.py", line 3, in <br>
from wtforms.widgets import html_params, HTMLString<br>
ImportError: cannot import name 'HTMLString'</p>

<p dir="auto">It seems that after the release of WTForms==2.3.0 webserver doesnt start<br>
Changing it back to WTForms==2.2.1 solves the issue</p>
<p dir="auto"><strong>How to reproduce it</strong>:<br>
Use WTForms==2.3.0</p>