Skip to main content

Hello everyone,



I’m facing an issue with the speed of the responses I’m receiving from the API.


I’m making 100 parallel calls from one user and repeating this process 10 times, resulting in less than 1000 calls per minute. Here’s the code snippet that I’m using:



_boxClientCredentialsGrant = new BoxCCGAuth(boxConfig);

_userclient = _boxClientCredentialsGrant.UserClient(_testUserId);



// This part in paralel 100 times

// iterate 10 times

var result = await _userclient.UsersManager.GetCurrentUserInformationAsync();






The blue line is the performance in average pro call in this scenario



I’m wondering if there are additional optimizations that I can implement to receive faster responses to these API calls and process them more quickly. Has anyone had experience with performance optimization? I’m questioning whether the current performance is acceptable or if there are further optimizations I can make on my end. For example, should I consider using an HTTP client instead of the SDK or any other approaches that I might not be aware of?



I would be grateful for any suggestions or guidance.



Thank you in advance.

Hi @dawid ,



I don’t think there is much SDK overhead when compared to a direct HTTP call.



However the data you go seems very excessive. If I understood correctly in the first cycle you got an average of 9 seconds per call?



For example I’m currently using a mobile 4G connection and the same call using curl is taking around 400 milliseconds:



curl -w "@curl-format.txt" --location 'https://api.box.com/2.0/users/me' \

--header 'Authorization: Bearer v1...IY'



Results in:



{

"type": "user",

"id": "20706451735",

"name": "CCG",

"login": "AutomationUser_1803368_9rbDFPFJSf@boxdevedition.com",

"created_at": "2022-09-15T12:56:38-07:00",

"modified_at": "2022-11-09T09:27:51-08:00",

"language": "en",

"timezone": "America/Los_Angeles",

"space_amount": 10737418240,

"space_used": 0,

"max_upload_size": 2147483648,

"status": "active",

"job_title": "",

"phone": "",

"address": "",

"avatar_url": "https://app.box.com/api/avatar/large/20706451735",

"notification_email": null

}



and:



     time_namelookup:  0.006777s

time_connect: 0.039072s

time_appconnect: 0.081502s

time_pretransfer: 0.081671s

time_redirect: 0.000000s

time_starttransfer: 0.400587s

----------

time_total: 0.400675s



Can you share your testing code?



Cheers


Hi @rbarbosa


thank you very much for your hint, which allowed me to definitively identify the error on my end.


As it turns out, I had mixed up Async/Await in a multithreading context at one point.


I don’t think the code would have helped anyone in that state.



After fixing it, the performance looks great. Thank you once again.





Best regards,


Awesome, thanks for sharing @dawid !!!


Reply