Hacker News new | ask | show | jobs
by Matthias247 1377 days ago
My thoughts as CDN engineer:

It can be a tiny amount more efficient since an async disk IO implementation might dispatch the file read() call to a thread pool, wait for the result, and then send the data back to the client. Makes 2 extra context switches compared to sending data from memory. Now if the user is super confident that the data is hot and in page cache then a synchronous disk read will fix the problem. Or trying a read with RWF_NOWAIT and only falling back to a thread pool if necessary.

On the other hand rendering a template on each request also requires CPU, which might be either more or less expensive than doing a syscall.

All in all the efficiency differences are likely negligible unless you run a CDN which does thousands of requests per seconnd.

In terms of throughput to the end user it will make zero measurable difference unless the box ran out of CPU.

1 comments

The file is most likely cached in memory ( OS ) even if there is a read I assume it's going to be faster vs running some code in Rust.