I have an AWS Lambda, based on typescript, that calls SQL Server (located on an AWS EC2 instance), using node-mssql
library for this purpose.
I would like to trace the request and find the bottleneck. In my code I can cover the calling method and calculate the time.
So, the request can be split into the following parts:
- init calling on Lambda's side
- the part from lambda to EC2 (network delay)
- the "incoming" part inside EC2 refers to the time when the virtual server calls SQL Server internally
- T-SQL query execution time
- the "outcoming" part inside EC2
- the part from EC2 to lambda (network delay)
- return the result to the calling code
I'm confident about step #4; I profiled the SQL query time, and it's quite small.
So, the problem lies in another step or steps.
I'm exploring X-ray and have configured it for calling S3 as an example, but there seems to be no way to profile the node-mssql
library (perhaps another library could work?). Therefore, I'm unsure how to implement this in practice.
My idea is that we can at least monitor the network parts (#2 and #6) because I don't see any barriers to observing network requests (but I did not find how to do it using X-ray). Additionally, since EC2 is part of the AWS family, it probably could provide us with some helpful insights or tools.
Any ideas and suggestions? :)
Thanks