Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

uWSGI Worker Crashes on Frequent OpenSearch Requests via opensearch_dsl #111

Closed
zaalgol opened this issue Jan 9, 2024 · 1 comment
Closed
Labels
bug Something isn't working

Comments

@zaalgol
Copy link

zaalgol commented Jan 9, 2024

What is the bug?

I am running a Python Flask server in a uWSGI workers.
The uWSGI crushes when the server makes a lot of requests to OpenSearch (50 requests in 40 seconds.)
It is worth noting that when I send a lot more requests to the server (200 in 40 seconds), but without the server calling the OpenSearch, the uWSGI does not crushes, indicating a problem in calling OpenSearch.
also, the open search does not show logs of errors.


This is the code:


from opensearch_dsl import Search, Q
…
    @cached_property
    def opensearch_client(self):
        secret = self.vault_client.read_secret(OPENSEARCH_AUTH_VAULT_LOCATION)
        return OpenSearch(hosts=config.get('OPENSEARCH_URLS_LIST'),
                             http_auth=(secret.get('opensearch_user'), secret.get('opensearch_password')))

     def get_recording_metadata_by_file_uuid(self, file_uuid):
        s = Search(using=self.opensearch_client, index=self.custom_index).query(Q('term', id__keyword=file_uuid))
        response = s.execute()
        if response.hits:
            return response.hits[0].to_dict()
        else:
            return None

How can one reproduce the bug?

send multiple requests to the flask server.

What is the expected behavior?

The uWSGI should not crush.

What is your host/environment?

Debian GNU/Linux 9

Do you have any screenshots?

No. the uWSGI just crashes.

Do you have any additional context?

The server runs in a docker container.

@zaalgol zaalgol added bug Something isn't working untriaged labels Jan 9, 2024
@saimedhi
Copy link
Contributor

Hello @zaalgol, please take a look at opensearch-py. The dsl client was merged into that repo and deprecated here.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants