salesforce-marketingcloud / FuelSDK-Python

FuelSDK for python
Other
126 stars 193 forks source link

Extreme performance issues in suds library #28

Open shawn-simon opened 10 years ago

shawn-simon commented 10 years ago

Hey,

I'm wondering if you guys noticed that when the Fuel SDK creates a SOAP request, it goes through extreme CPU usage. On a new macbook pro, it takes about 10 seconds to build an object. On a medium Amazon AMI, it takes over 1 minute. This is just to build a instantiate a Python object. It looks like it occurs in the suds library. Haven't spend too much time looking into it.

cmoad commented 10 years ago

Do you have a code sample? Also, what version of python are you using? I haven't seen this sort of delay in tests.

shawn-simon commented 10 years ago

This is the code were using, it's Python 2.7. When post() is called, it takes a minute to build the soap request (10 seconds on my dev machine though.) During that time, my computer heats up and the fans kick on. I haven't looked at this in a couple weeks but it seemed like an issue in the suds library where it builds the class from the wsdl. The actual network trip only takes about ~150 ms.

      postTsd = FuelSDK.ET_TriggeredSend()
      postTsd.auth_stub = self.soap_api_client
      postTsd.props = {
         'CustomerKey' : tsd_key,
         'Name' : tsd_key,
         "IsMultipart": True,
         "IsWrapped": True,
         'Email' : {"CustomerKey": email_key},
         "SendClassification": { "CustomerKey": self.send_classification }
      }
      response = postTsd.post()
P120D1GY commented 8 years ago

Has anyone found a resolution to this issue? We're seeing this same issue, a triggered send using this SDK is taking ~24 seconds to complete.

import FuelSDK

def triggeredsend_handler(event, context):
    try:
        # Variables
        emailTemplate       = "{0}".format(event['emailTemplate'])
        email               = "{0}".format(event['email'])
        userID              = "{0}".format(event['userID'])
        firstName           = "{0}".format(event['firstName'])
        locale              = "{0}".format(event['locale'])
        passwordResetLink   = "{0}".format(event['passwordResetLink'])

        # Create an instance of the ET_Client class:
        debug = False
        myClient = FuelSDK.ET_Client(False, debug)

        triggeredsend = FuelSDK.ET_TriggeredSend()
        triggeredsend.auth_stub = myClient
        triggeredsend.props = [
            {
                "CustomerKey": emailTemplate
            }
        ]
        triggeredsend.attributes = [
            {
                "Name": "Email",
                "Value": email
            },
            {
                "Name": "UserID",
                "Value": userID
            },
            {
                "Name": "First_Name",
                "Value": firstName
            },
            {
                "Name": "Locale",
                "Value": locale
            },
            {
                "Name": "PW_Reset_Link",
                "Value": passwordResetLink
            }
        ]
        triggeredsend.subscribers = [
            {
                "EmailAddress": email,
                "SubscriberKey": email
            }
        ]
        sendResponse = triggeredsend.send()

        return {
            'status': str(sendResponse.status),
            'code': str(sendResponse.code),
            'message': str(sendResponse.message),
            'count': str(len(sendResponse.results)),
            'results': str(sendResponse.results)
        }

    except Exception as e:
        print 'Caught exception: ' + e.message
        print e
        return e