I am currently using Amazon EC2 Instance for handling communication of our IoT products (development stage). I am not quite experience in scaling the specs of our instance to overcome the increase of the devices in the future. So, I am thinking of using AWS Lambda and move all the business logic from the EC2 instance to lambda. But now, there are a couple of things that I don't understand.
Under advance settings of my lambda function I can set the memory allocation for my Lambda function. If I set a memory of 512mb, will this scale up automatically if my function needs more than 512mb of memory?
Is the memory that I set for the lambda function used per execution? For example, I have 30 requests that needs to be processed concurrently. If my Lambda function will be executed 30 times, does that mean my 30 executions can only used up to 512mb of memory? Or I have 512mb of memory that can be used per execution?
The documentation states that Amazon might reuse instance of function. So If I have 2 requests coming at the same time, and Amazon reuse the existing copy of function, does that mean there will be a chance that an instance of my function will process two request at a time?
There will be a connection to database established every time a request is made. Will this connection be retained? If it is retained, then will the connection be terminated when the function instance is terminated?