Hey Guys, how you doing? We're having issues with ...
# support
f
Hey Guys, how you doing? We're having issues with the node.js sdk. Once a while, track calls take a lot of time - up to 20 seconds for a single event. Is there an issue or am I missing something? Thanks!
m
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
k
Hey Jonathan, Can you please share your SDK initialization snippet ?
f
Hey Desu, sorry for the late reply. sure:
Copy code
this.client = new Analytics(configService.rudderstackApiKey, configService.rudderstackDataPlaneUrl);
and the usage is something like:
Copy code
this.client.track(event, (err) => {
          if (err) {
            reject(err);
          }
          resolve();
        });
If it's not clear, let me know and i'll try again 🙂
c
Hello @future-nest-36254, Can you please clarify if the request is getting fired and takes more than 20sec to respond or if a track event takes place but takes more than 20 seconds to trigger a request?
f
Hey Georgios. it's getting fired fast but takes 20 sec to respond.
Hey Guys, anything new? need more info?
c
Hello @future-nest-36254, Are there any logs that you can provide in order to investigate with our services team please? Do you have any more info regarding the requests that cause delayed responses, like very large payload for example, or is it just random? what is your flashAt and flushInterval value is you have set any other than the defaults?
f
What kind of logs do you need? I'll make sure I'll send them. the payloads are big but not huge.. not more than 1.5kb. not changing the flash values..
b
also what is your writeKey and also dataplane url?
f
can you get it from the workspace name? those are secrets..
?
Hey Guys, anything we can do?
c
what is your workspace? can you share it please?
f
sure. the workspace name is:
goperfectmatch
is it enough or do you also have an id that I can send?
c
I'll look into it and come back to you if more info is needed, thanks Jonathan
f
cool. thanks Francesco
👍 1
c
@future-nest-36254 can you tell me
sourceID
and
destinationID
for which you're experiencing these performance issues please?
f
the sourceId is:
2AslFRN56GzUKAq9p1VsH4QYsXV
we have 2 destinations for this source: 1. Kafka:
2BRG0NrtnvrWv2JIaHLs4V79685
2. JUNE:
2GVawiCiiilwoqtKf1gFpcraKq2
👀 1
c
@future-nest-36254 I've been looking at the metrics and I can't find anything wrong. just to make sure, can you please confirm that the 20s that you see are to get an HTTP response back? or maybe you meant that 20s pass until you see the message delivered to the destinations? If it's the former I checked our gateways for the last seven days and very rarely we take more than 1 second to reply. the max recorded time was 1.4s.
f
Thanks for the thorough check! The issue is getting the http response back and not in the destination. I added a time duration log and the results are quite surprising. it takes 20 sec for every request. attaching the code snippet and the results.
Copy code
return new Promise((resolve, reject) => {
      try {
        const invoked = new Date();
        this.client.track(event, (err) => {
          console.log((new Date().getTime() - invoked.getTime()) / 1000);
          if (err) {
            reject(err);
          }
          resolve();
        });
      } catch (err) {
        reject(err);
      }
    });
results: 20.166 19.027 19.964 20.093 19.893 20.042 20.012 20.108 20.031 20.221 20.022 20.178 20.045 20.107 20.023 20.03 20.171 20.209 20.069 20.03 20.065 20.06 20.158 20.179 20.235 17.819 20.023 19.931 20.045 20.165 20.168 20.21 20.03 20.072 20.057 19.987 19.7 20.061 20.166 20.066 20.088 20.166 20.028 20.067 20.147 19.7 20.662 19.755 20.145 19.817 19.796 19.839
@careful-cat-37761 maybe it's a configuration issue?
c
I see that you have many sources and destinations set. this happens only for that source that you mentioned earlier?
does this happen only when sending events for this configuration?
f
it happens for all the node.js sources. the 'javascript' sources seems to work better.
✅ 1
c
Hello @future-nest-36254, Based on the conversation I believe that there is a miss understanding here and not an actual issue of delayed responses. The NodeJS SDK sends events in batches, not one request per event. From the shared code I see above, this is the invoked timestamp of when the event was triggered and added to the batch. Not when the request was fired in order to submit the batch to data plane. The submission of the batched requests is based on the flushAt & flushInterval configuration options that are documented at https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-node-sdk/#sdk-initialization-options JS SDK does not have batching mechanism, maybe that is the reason of the confusion.
Try to amend the flashAt and flushInterval values to your preferred values please and let us know if this resolves the issue.
f
I see. thanks @cool-lunch-88059. make sense. So the track function call just adds the specific event to the batch? if so, how come it takes that long? the flush is async or this function waits for sync flush? What is the best practice for using this function?
c
The track function itself does not take this long to execute. When you pass a callback method as argument to track (or any other method like page etc) this callback is going to invoked after successful response of the batch request. Track event being added in the event queue in memory is instant. what is the use case you want to cover and have an issue with? If you want to fire a callback after each event is successfully submitted to data plane you might want to use flushAt = 1. This will be firing a request per event though so not suggested from networking performance point of view
f
Thanks for the explanation! I'm using kafka to consume events and report them using your sdk. I wanted to use callbacks to make sure that I don't lose events, so if the request fails, I'm throwing an exception and the kafka message will go to a dead letter queue. I guess that I'll need to choose if i'm using redis as your doc suggest or using flushAt =1 as you mentioned. so basically if I do several track calls with callbacks, the callback will be called many times when the queue is flushed?
c
You will get one execution of the callback per queued event, that has a callback as argument, once the flush request has been completed with success. You could also try to use a custom error handler (passed as an option) that is executed once on each flush response error maybe to create your own retry implementation if you do not want to use redis. You could also potentially explore passing your own axios instance where you can define interceptors to implement your retry logic there. If a flush request fails you would want to resent the full batch. Errors are axios errors so they should contain the request were you can get the body and throw exception for all messages in the items array
🙌 1
🙏 1