-1

I have implemented a web service using ASP.NET WebAPI framework.

The response time is faster in my local system (target framework4.5) that deploying to the server.

After deployment to Windows2012R2 IIS8.5, a response takes about 30 seconds for each request. I have tried the sample web service without any data retrieval from database. This also takes about longer time. I installed Fiddler and identified that TTFB took about 26 seconds.

I created the web service using this url:

https://www.c-sharpcorner.com/article/create-simple-web-api-in-asp-net-mvc/

Even displaying "welcome" message itself takes about 30 seconds. Any thoughts on where to look to investigate the performance issue? Here is sample code as in URL

namespace Demo1.Controllers
{
    [System.Web.Mvc.SessionState(System.Web.SessionState.SessionStateBehavior.Disabled)]
    public class DemoController : ApiController
    { 
     public string Get()
        {
            return "Welcome To PARIS Web API";
        }
        public List<string> Get(int Id)
        {
            return new List<string> {
                "Data1",
                "Data2"
            };
        }

} }

Nata
  • 1
  • 1

1 Answers1

0

Performance of compiled code on two different servers is almost always related to the physical resources that have been made available at the time to code runs.

Keep in mind that we as developers usually code on PCs with far better specs than the servers we deploy to!

For API deployments, it is common to deploy to cloud or minimal servers that have either reduced CPU or Core counts, or the resources available to your deployed app have been restricted to allow for the server to run multiple apps.

  • Sometimes to reduce costs we deploy to servers with the resources that we think our app needs, without remembering that the OS of that server will have basic requirements that will need to be met.

You have already isolated the issue about the available bandwidth between the deployed server and the database, for other punters keep this in mind as a potential bottleneck, keep your database close to your APIs.

If every request to a simple site is slow, check the logs on the slow server, look for errors or indications of slow starts, or that the app is restarting for every request. It is common and we accept slow cold starts of our web apps, but the web app should remain alive between requests, even if it is session/state less.

It would help to know if you are deploying to a physical server, virtual machine, cloud app service or a container host, if the server is in the cloud or on the ground and if you known the general bandwidth available from the server?

Just spit-balling, this was an old .Net gotchya: Check that your server or firewall is not blocking outbound internet calls!
Due to low level calls in .Net trying to perform SSL Certificate Revocation checks your code may wait at startup trying to make external calls. This post discussed options to disable that. Something to try if all else fails.

Chris Schaller
  • 13,704
  • 3
  • 43
  • 81