问题
I would like to get the (AWS Lambda container) instance ID that my function is running in.
For now I would just log it - it would help me when debugging issues with my caching algorithm: I could identify which invocations were happening in the same instance.
I looked at the docs for the context object and don't see anything there.
I could do it manually - and I'll put that below as my fallback answer - but I thought I would check whether some sort of real instance ID is available somehow.
回答1:
Could just generate a random GUID save that in global. (I'm just starting to look at this issue of container re-use and the potential for data caching, but I assume that node's 'global' object remains intact when an instance is re-used.)
来源:https://stackoverflow.com/questions/43213732/how-can-i-uniquely-id-the-aws-lambda-container-that-my-function-is-running-in