I have .net core MVC API implementation. In my controller I try to query for 800 records from DB. In result my response body size is abound 6MB. In that case response time is over 6s. My service is in AWS cloud.
I made several tests to make diagnostic of service. In all these scenarios I still ready 800 records from DB. Here is list of my experiments:
- Return only 10 records - my response time were under 800ms always and size of response body 20kB.
- Return only 100 records - my response time were over 800ms but not timeouts and size of response body 145kB
- Try to use my custom json serialization in controller
await JsonSerializer.SerializeAsync(HttpContext.Response.Body, limitedResult);
- a bit better result but like 10% only
- Return only 850 records - my response time were over 6s but and size of response body 6MB
In service I don't have problem with memory or with restart service.
Looks like for Kastrel the problem is to serve large response data.
My objections are connected with buffers I/O which for large response will use disk what can affect performance of AWS docker image.
Question is how to optimize Kastrel to serve large response size?
UPDATE:
I enabled zip compression on server side. My files are compressed quite good because of json format. But result is exact the SAME. Network bandwidth is not a problem. So looks like between my controller and compression is bottleneck. Any suggestion how to configure .net core service to handle large response (>1 MB)?
question from:
https://stackoverflow.com/questions/65870520/kastrel-tuning-for-large-1mb-response-json 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…