Dockerized API Server Running in Kubernetes Slow Response Times?

6/20/2018

I believe I am running into an issue with Kubernetes.

I am running a Flask app that is being served with GUnicorn that has been Dockerized. Running the Docker image locally, I can request my homepage and get a response in about 200 ms. When I deploy the image to my Kubernetes cluster (one node, two pods, node has 3.5GB memory and 1 CPU, hosted on Azure), the same request/response takes 2 seconds.

This homepage route does not rely on any sort of DB connection (it just returns a few lines of inline html). Looking at the kubernetes dashboard, the pods show 0 CPU usage and a constant amount of memory usage (~80 MiB).

When I check the logs for the pods through the Kubernetes dashboard, I see several hundred lines, all saying:
[2018-06-20 19:00:01 +0000] [7] [DEBUG] Closing connection.
This is a debug log from GUnicorn.

What is the reason for the increased response time? What can I do to mitigate this?

-- Chantelle Chan
docker
flask
gunicorn
kubernetes
python

0 Answers