Python code performance in Kubernetes pods

is there a way how to improve Python performance in Kubernetes (containerd)? We make some tests using the same code and it looks like in the container it executes twice slower than on bare metal.

I find a tag seccomp=unconfined (Seccomp security profiles for Docker | Docker Documentation) but don’t know if it is secure to use it on production environment.

Is there anything else to fix that?

Cloud being used: GKE on GCP

Any response will be appreciated

Are there any resource restrictions specified for the container, like memory and CPU?
Is it CPU, memory or I/O bound?
If it’s I/O bound, is it network or storage, read or write?
You have to provide more info.

Hi adampl,
the only one restriction is:

            cpu: 150m
            memory: 600Mi
            cpu: 500m
            memory: 2000Mi

It is a small container with celery application and there is a script in Python for healthcheck verify of the app. Generally, I think, it is not related directly to Python, but for all codes. We had also a bash script wich have only one line of code, but the situation is the similar - works slowly.

celery -A celery:celery_application inspect ping -d HOSTNAME

Well, I think these restrictions are quite tight… 50% of a single CPU core for a whole Celery worker? How many parallel processes it runs?

As a rule, you should have 1 CPU core per process, including the root and all child processes. If the code you run is I/O bound, you can try with less CPUs.

Show me at least the container command.

Regarding the Bash script, it’s a single line but under the hood it invokes Python with the Celery command code :slight_smile: