Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

ASP.NET Zero and AWS Lambda slow startup #6950


User avatar
0
aptys created

We're trying to get ASP.NET Zero to run on AWS Lambda (the Amazon version of Azure Functions).

Each call to the service appears to take 2-4 minutes to execute. I've traced it down to it spending almost all of that time in the app.UseAbp() function within the Startup.Configure class.

Question: Do you have any idea what it could be spending it's time on here, or is there any way to tell what part of UseAbp() is taking all this time?

Additional Details:

We've been able to successfully build and deploy the .NET Core 2.1 version (using ASP.NET Zero v6.3.1.) to AWS Lambda, after having followed the same steps outlined at https://forum.aspnetboilerplate.com/viewtopic.php?p=29608.

We've been able to see where it's taking it's time by putting some additional diagnostic logging in various places in the Startup class.


3 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi @jsklare

    Configure method should only run once when the app is started. So, is it possible that your app is starting again every time when you make a request to a service ? Maybe AWS is preparing a new instance for each of your requests. I'm not familiar with AWS by the way.

  • User Avatar
    0
    aptys created

    I believe you are right about the configure being called for each instance of the service.

    It appears as though the issue may have been a combination of several things:

    • Log4net logging was missing because I disabled the rolling log file appender, since we wouldn't have access to write to a log file in the Lambda environement. I've since changed this to a ConsoleAppender, since the console output gets automatically ingested into CloudWatch logs.
    • The database could not be accessed do to security restrictions on the Lambda environment
    • Cold startup of the application takes a pretty long time, maybe (1-3 minutes). I have not yet diagnosed what the cause of this is. Once it's warm, requests are processed very quickly.

    Once I fixed the database security issue, increased the timeout for the Lambda's from the default 30 seconds, upped the memory limit for the Lambda from 256 to 512, and fixed the log4net configuration, I was able to get the system to start returning some requests.

    I will be continuing to work with this configuration and will write another update once I know more.

  • User Avatar
    0
    ismcagdas created
    Support Team

    Thanks a lot for sharing your experience. We will be happy to help if you face any other problem.