API taking more than 3s for a simple contact search

Your software
My Mautic version is: 4.0.1
My PHP version is: 7.4.3
My Database type and version is: 5.7

Your problem
My problem is:
Currently i only have 3k contacts and using the API for a simple search, each request is taking more than 3s. Using the web interface it only takes milliseconds. I easly reach 100% CPU percentage executing multiple searchs at the same time, like 5 requests.
I’m using php-fpm and basic auth.
My server has 2 CPU and 4 GB of RAM.

If someone is facing the same issue or has any idea in how to solve this situation, i would really appreciate the help.

The problem seems to be related with the “Basic auth”. I have implemented the oAuth2.0 and the response times reduced to under 1s.

I would like to confirm that there seems to be a problem with Basic Auth.

A simple GET on /api/contacts/20 with Basic Auth runs 0.7 seconds on my system. With OAUTH2 in some ms.

The mautic php process has high cpu usage in that 0.7 seconds.

Mautic 5.0.2