How to speed up OfflineUserDataJobOperation for over 1M+ customer match?

239 views
Skip to first unread message

Lin Chen

unread,
Jan 24, 2022, 11:22:40 AM1/24/22
to Google Ads API and AdWords API Forum
Hi Google Ads Team, 

Thanks for posting this tutorial and I tried to follow every step to add users to customer match user List. My problem came with the huge volume of customers. I have around 1M+ users want to upload to that user List and here's my code to build the operation list.

10k users adding to the operation list takes around 7mins and it seems too slow. Any code improvement and opinion will be appreciated!

def _build_offline_user_data_job_operations(df):
    size = df.shape[0]
    operations_list = []
    for i in range(0, size-1, 50000):
        operations = []
        df_copy = df.iloc[i:min(size, i+50000)]
        for row in df_copy.itertuples():
            operations.append(_build_single_offline_user_data_job_operation(row[1], row[2], row[3], row[4], row[5], row[6]))
        operations_list.append(operations)
    return operations_list
       

def _build_single_offline_user_data_job_operation( email, first_name, last_name, postal_code, country_code,  phone_number):

    user_data_operation = client.get_type("OfflineUserDataJobOperation")
    user_data = user_data_operation.create
    user_identifier = client.get_type('UserIdentifier')
    user_identifier.hashed_email = _normalize_and_hash(email)
    user_identifier.hashed_phone_number = _normalize_and_hash(phone_number)
    address_info = client.get_type('OfflineUserAddressInfo')
    address_info.hashed_first_name = _normalize_and_hash(first_name)
    address_info.hashed_last_name = _normalize_and_hash(last_name)
    address_info.country_code = country_code
    address_info.postal_code = postal_code
   
    user_identifier.address_info = address_info
    user_data.user_identifiers.append(user_identifier)
    return user_data

Google Ads API Forum Advisor

unread,
Jan 25, 2022, 3:16:10 AM1/25/22
to lc...@webstaurantstore.com, adwor...@googlegroups.com

Hi Lin,

Thanks for reaching out to the Google Ads API Forum.

Since OfflineUserDataJobOperation is slow, I suggest reaching out to the client library developers by going to the "Issues" tab of your Python client library's GitHub and clicking "New issue" to open up a case. For example, here is the Issues page for the Python library. I asked this because, performance of operation in your code depends on the environment in which you are running your python program (e.g. OS Platform and Distribution, Python version, etc.).

Let us know if you have any further questions.

Regards,

Google Logo
Yasar
Google Ads API Team
 


ref:_00D1U1174p._5004Q2VOxl2:ref

Lin Chen

unread,
Jan 25, 2022, 9:19:37 AM1/25/22
to Google Ads API and AdWords API Forum
Hi Yasar,

Thanks for getting back to me! Do you mean currently there is not any good optimization on the code itself?

Thanks,
Lin

Google Ads API Forum Advisor

unread,
Jan 26, 2022, 1:50:36 AM1/26/22
to lc...@webstaurantstore.com, adwor...@googlegroups.com

Hello Lin,

Thanks for getting back to us.

As mentioned by my colleague (Yasar), performance of operation in your code could also depend on the environment. However, you can also refer to this guide for the list of Best Practices related to optimization. In addition to that, we recommend that you reach out to the client library owner via this link for more insight on possible code-related optimizations for uploading your audiences.

In the event that you are also experiencing slowness in other API services, let us know and provide the complete API logs (request and response with request-id) via the Reply privately to author option or via our support alias (googleadsa...@google.com).

Regards,

Google Logo
Mark Kevin Albios
Google Ads API Team
 


ref:_00D1U1174p._5004Q2VOxl2:ref
Reply all
Reply to author
Forward
0 new messages