"client" object management in application

In scalable applications (e.g., Django), is it preferable to instantiate the OpenAI object in every module, or should it be handled as a singleton throughout the entire application?

The “singleton” approach relies on a function (called something like get_client()) that shares the same instance of the client across the entire application, using the global hotkey.

This approach seems more reasonable to me, but sometimes (especially when operations are parallelized via multiprocessing) I receive HTTP 502 errors in about 1% of the invocations (still below the rate limit). These HTTP errors are correctly handled by retry logic, and the second attempt succeeds.

In my past projects (where I instantiated the client in each module), this never happened.

Do you think that these 502 errors might be caused by sharing the client instance?