AppSearch using few features throwing error 502 when CPU consumption increases

Hello everybody! I'm using AppSearch as a search engine for the production environment of my marketplace, hosted in docker, same as the single instance Elastic Search.
I'm not using appsearch logs, alias, boosts, etc.. all the configuration is sent in each API request. I just use AppSearch to build a "nice" Elasticsearch request, using all the best practices AppSearch know about how to make a full-text search request.
The problem I have is that when the demand increases, say 80% CPU is used, AppSearch continues throwing error 502. At that time, elasticsearch is around 30% CPU.

I thought about consuming elasticsearch directly, without AppSearch in the middle since I'm not using its advanced features, however the search script generated by AppSearch is soooo complex, that I supposed it has a lot optimizations that are worth the cost of this intermediary between my API and Elasticsearch.

So my question is how to avoid the 502 errors when I still have 20% CPU unused. Is any way to change that behavior in AppSearch? Or somebody found a way to quit using AppSearch, mantaining the same level of effectiveness, still having a maintainable code?

Thanks!

Hi @aa1t !

502 is a bad gateway error, and probably means that App Search is encountering some kind of problem. Have you checked out App Search logs for any specific cause?

If you're not using App Search features, it could be worth checking Search Applications as a way of defining a search template and use it for searching in Elasticsearch.