Supreet
Supreet

Reputation: 2541

Handle thousands of requests & file streaming with low memory usage

I am working on .net core API where i had to finalize an approach for copying files. File Size may vary from 1 MB to 25 MB. Currently we are getting 20 to 25 k hits per second. Is there any solution Or approach where multiple request can be handled with low memory usage.

Is there something like transmitFile in .net Core?

Upvotes: 1

Views: 687

Answers (1)

Daboul
Daboul

Reputation: 2753

First thing that comes to mind, when you are dealing with I/O bound operation such as DB or file system, would be to make sure you deal with everything in an asynchronous way. You don't want your process to stop because you are waiting for your hard drive to finish. Dot Net Core is massively using it and the syntax is fairly simple, the concept behind it, though, is not often well understood. You could have a look at article such as https://ayende.com/blog/173473/fun-async-tricks-for-getting-better-performance if it is not completely clear to you.

Then, on top of it, if you want to avoid allocating to much memory on the server, you should be careful reading the file bit by bit instead of loading the full 25Mb as soon as you enter your code.

Async + small buffer should make it as performant and low-foot-print as possible.

Upvotes: 1

Related Questions