I have a .net web service (Web API 2) that takes requests to get data from a database. The returned data is not very large, just 1-3 kb usually (about 1-15 rows from the database). I set it up in IIS and ran some bulk testing on it, where it gets hit a lot for an hour or so, so it is getting several thousand requests. When I look at the w3wp.exe (IIS Worker process), the memory just keeps increasing until it gets to over 5 gb and the CPU usage gets near 100% and then eventually the web service stops working. The server has 16 gb of RAM, we just increased it from 8. Is 5 gb of memory normal? That seems like a lot, I would have assumed garbage collection would handle this better. I am not very experienced in using the performance monitor or other things to troubleshoot problems like this.
Any suggestions on what I can look at? Could there be a memory leak? Should I try having the app pool recycle when it hits a certain memory amount?
Update- we have another .net web service that does not even access a database or any external files or anything, and it is acting the same way- memory just keeps increasing. Our plan is to probably set the app pool for each to recycle every x minutes or when it gets to a certain memory amount.
Here is an example of a typical function in the API:
[Route("patient/{patientKey}/activations")]
public async Task<IHttpActionResult> GetActivations(int patientKey)
{
try
{
ActivationList actList = new ActivationList();
actList.Activations = await _actProc.GetByPatient(patientKey);
return Ok<ActivationList>(actList);
}
catch (Exception ex)
{
return new BadRequestWithInfoResult(Translators.makeXML<ErrorReturn>(CreateError(ex)));
}
}
public async Task<List<Activation>> GetByPatient(long patientKey)
{
using (var dbConn = _database.CreateConnection())
{
List<DBActivation> lst_Activation = await dbConn.FetchAsync<DBActivation>("select * from fact.Activation where PatientKey = " + patientKey.ToString());
List<Activation> Activations = lst_Activation.Select(x => _mapper.Map<Activation>(x)).ToList<Activation>();
return Activations;
}
}
>(lst_Activation)`
– penleychan Apr 16 '19 at 16:04