cloud-sdk-js icon indicating copy to clipboard operation
cloud-sdk-js copied to clipboard

Performance Issue with @sap-cloud-sdk/http-client

Open zarar1210 opened this issue 1 year ago • 10 comments

Problem Statement:

I am using Node.js version 20 and the @sap-cloud-sdk/http-client to make POST requests, but I am encountering APIs performance issues. However, when using Node.js version 18 with sap-cf-axios, the performance is better, and I receive APIs responses more quickly.

Any one please help me out here on performance issues ?

Note: We are using Cloud SDk library ->@sap-cloud-sdk/http-client - npm (npmjs.com) and it function executeHttpRequest to send request to convergent mediation system(On premise ) via cloud connector .The connectivity is made using Destination which is maintained in BTP subaccount and same for sap-cf-axios,

Function -1

const httpclient = require('@sap-cloud-sdk/http-client');
async function callSoapApi(data, req, res) {
    await httpclient.executeHttpRequest(
        {
            destinationName: destination
        },
        {
            method: 'POST',
            url: req.url,
            data: data,
            headers: {
                SOAPAction: "SOAP ACTION NAME"
            }
        },
        {
            fetchCsrfToken: false
        }
    ).then(response => {
        res.status(200).send(response.data);
    }).catch(error => {
        generateErrorMessage(req, res, error);// Separate function for error handling
    });
}

Function -2

let SapCfAxios = require('sap-cf-axios').default;

let callSoapApi = async (data, req, res) => {
    try {
        let axios = SapCfAxios("Destination_name");
        let dataResp = await axios({
            method: "POST",
            url: req.url,
            data: data,
            headers: {
                SOAPAction: "SOAP ACTION NAME", // Replace with your SOAP action
            }
        });
        res.status(200).send(dataResp.data);
    } catch (error) {
        generateErrorMessage(req,res,error); //Separate function for error handling
    }
}

zarar1210 avatar Oct 03 '24 18:10 zarar1210

Hey @zarar1210, could you share some more details on how much performance difference you see and also compare it with the same node version. The SAP Cloud SDK uses axios underneath as well.

marikaner avatar Oct 17 '24 12:10 marikaner

image (5)

Hi @marikaner , Thank you for reply, We were conducting some performance testing using the JMeter tool. Here is a screenshot. We have two API endpoints.

zarar1210 avatar Oct 17 '24 12:10 zarar1210

Hi @marikaner , FYI- We have deployed nodeJS application (microservice) to Cloud Foundry in Canada (ca10) region. This application internally calls https REST endpoint in Convergent mediation system(On premise)

We are using sap-cf-axios (1.0.2) to send request to convergent mediation system(On premise ) via cloud connector .The connectivity is made using Destination which is maintained in BTP subaccount.

Issue : The performance is bad when we use Node js version 20 with stated axios Library.

However if we switch to version 18 with same libraries performance is 3 times better

zarar1210 avatar Oct 17 '24 12:10 zarar1210

Hey @zarar1210, thank you for the screenshot. I am not 100% sure how to interpret this though, because I have the impression that the categories are not necessarily comparable, but it looks like the SAP Cloud SDK performs best.

Am I understanding correctly that the sap-cf-axios library has better performance in node 18 than node 20? How is that related to the SAP Cloud SDK?

marikaner avatar Oct 17 '24 12:10 marikaner

Hey @zarar1210, thank you for the screenshot. I am not 100% sure how to interpret this though, because I have the impression that the categories are not necessarily comparable, but it looks like the SAP Cloud SDK performs best.

Am I understanding correctly that the sap-cf-axios library has better performance in node 18 than node 20? How is that related to the SAP Cloud SDK?

Hi @marikaner , I agreed, We are getting quick responses when using the sap-cf-axios library with Node.js version 18. However, with SAP Cloud SDK on Node.js version 20, we are not able to achieve the same quick response times. Is there something missing in the code functionality or any other issue?"

zarar1210 avatar Oct 17 '24 12:10 zarar1210

I am not aware of any issues yet. You also pointed out, that sap-cf-axios is significantly slower in node 20, right? Did you compare sap-cf-axios with node 18 vs SAP Cloud SDK with node 18 and sap-cf-axios with node 20 vs SAP Cloud SDK with node 20? Only then this would be a fair comparison, right?

I could imagine that there might be some change in node 20 that might be related to that.

marikaner avatar Oct 17 '24 13:10 marikaner

I am not aware of any issues yet. You also pointed out, that sap-cf-axios is significantly slower in node 20, right? Did you compare sap-cf-axios with node 18 vs SAP Cloud SDK with node 18 and sap-cf-axios with node 20 vs SAP Cloud SDK with node 20? Only then this would be a fair comparison, right?

I could imagine that there might be some change in node 20 that might be related to that.

Hi @marikaner , We are using this SAP Cloud SDK , "node": "20.16.0",, and "npm": ">=10.8.2" and we did try with version 18 as well performance is same while it is better with Node js version 18 and axios

zarar1210 avatar Oct 17 '24 13:10 zarar1210

Were you able to identify, where the time is lost?

marikaner avatar Oct 17 '24 13:10 marikaner

and just to make sure, which version of the SAP Cloud SDK for JS are you using?

marikaner avatar Oct 17 '24 14:10 marikaner

and just to make sure, which version of the SAP Cloud SDK for JS are you using?

Hi @marikaner , We are using this for now- "@sap-cloud-sdk/http-client": "^3.22.1", and "node": "20.16.0", "npm": ">=10.8.2"

zarar1210 avatar Oct 17 '24 14:10 zarar1210

Hi @zarar1210,

your investigation seems to indicate that it is likely caused by node rather than the Cloud SDK. We do not know what part of node seems to have caused your loss in response time, but I would recommend opening an issue with node instead, if the loss in response time is too significant.

I will close this issue here, as there seems to be nothing we can do about it.

tomfrenken avatar Nov 18 '24 14:11 tomfrenken