Hi!
I've been using Cloud Retail and Recommendations AI since last November for a customer project.
In short, we're sending personalised newsletters with recommended products (Google Merchant Center) for each user who signed up for receiving emails.
I have a file consisting a list with user_ids and visitor_ids stored as tuples. For every tuple in that list, I send the a prediction request and return the associated recommended products. Later, the list is updated with the users' recommended products and I can update our CRM system in regards to these new properties. All well and good.
However, this is done in Cloud Functions, and I saw no problem with this when the list had 4000 users. When it was scaled up to having 25 000 users the Cloud Function times out! It's not even half way after the 9 minutes.
I, therefore, want to rewrite the program and make the predictions run asynchronously and be able to run a bunch of them in parallel.
As of now, I've tried changing the code to use PredictionServiceAsyncClient. What's weird is that our new code works on and off. Mostly, it returns:
raise exceptions.from_grpc_error(rpc_error) from rpc_errorgoogle.api_core.exceptions.ServiceUnavailable: 503 Getting metadata from plugin failed with error: None could not be converted to unicode
Then I might execute the same code again, and it runs successfully. I can't seem to find any consistency in when this error is raised and not.
I've painted myself into a corner and I find very few, in fact no, examples of how this client are or should be used. Should it even be possible to run parallel requests on a PredictionServiceAsyncClient? I'm using a service account for local testing and no specific headers are set. I initiate the async client once.
And for what it's worth: I'm not very experienced with either Python nor Google Cloud. I might be overcomplicating things, but I was really hoping this was possible to solve with the async client like I'm trying to do now.
More examples of Recommendations AI usage are much wanted!