I want to see this taken to the logical extreme. A real OS with actual drivers (no unikernel, no virtio) for a small set of hardware that only serves static pages. No need for virtual memory. Just hardcode the blog posts right into the OS and use the most minimal TCP stack you can make.
Seems like a case for a unikernel running on bare metal. No copying bytes across kernel/user, no context switching at all.
Serving a high-performance blog solely from memory, using Rust
21–30 of 143 posts
Re: Serving a high-performance blog solely from memory, using Rust
#22Great blog by the way :)
Re: Serving a high-performance blog solely from memory, using Rust
#23Question for the author: do you have numbers to share about performance relative to other static site servers? Great blog by the way :)
Re: Serving a high-performance blog solely from memory, using Rust
#24I want to see this taken to the logical extreme. A real OS with actual drivers (no unikernel, no virtio) for a small set of hardware that only serves static pages. No need for virtual memory. Just hardcode the blog posts right into the OS and use the most minimal TCP stack you can make.
I guess Unikraft is that, kinda? https://github.com/unikraft/app-nginx
Re: Serving a high-performance blog solely from memory, using Rust
#25I am too much of an OCD perfectionist and don't have the guts to ship this often.
Re: Serving a high-performance blog solely from memory, using Rust
#26Earlier quoted context omitted.
If the executable is on disk, it can be paged out unless you've used mlock() to tell the kernel to keep it resident.
Interesting. I've never heard of that happening before. Can you link a reference to where I can find out more about that aspect of the linux memory subsystem?
There are a few relevant bits to this. You can MAP_POPULATE the file to prepopulate the entries and you can MAP_LOCKED to MAP_POPULATE + lock the pages in (unreliably). As mentioned in the man page for mmap MAP_LOCKED has some failure modes that you don't get with mlock.
https://www.man7.org/linux/man-pages/man2/mmap.2.html
I also found this page: https://eklitzke.org/mlock-and-mlockall
Oh, and this: https://access.redhat.com/documentation/en-us/red_hat_enterp...
Re: Serving a high-performance blog solely from memory, using Rust
#27I want to see this taken to the logical extreme. A real OS with actual drivers (no unikernel, no virtio) for a small set of hardware that only serves static pages. No need for virtual memory. Just hardcode the blog posts right into the OS and use the most minimal TCP stack you can make.
Seems like a case for a unikernel running on bare metal. No copying bytes across kernel/user, no context switching at all.
Re: Serving a high-performance blog solely from memory, using Rust
#28Earlier quoted context omitted.
If the executable is on disk, it can be paged out unless you've used mlock() to tell the kernel to keep it resident.
Interesting. I've never heard of that happening before. Can you link a reference to where I can find out more about that aspect of the linux memory subsystem?
On an intuitive level, think of swap as being a place the kernel can put memory the program has written. When you malloc(4096) and write some bytes into it, the kernel can't evict that page to disk unless there's some swap space to stick it in. However, executables are different because they're already on disk -- the in-memory version is just a cache (everything is cache (computers have too many caches)). The kernel is allowed to drop the copy of the program it has in memory, because it can always read it back from the original executable.
[0] https://man7.org/linux/man-pages/man2/mlock.2.html
[1] https://ftp.gnu.org/old-gnu/Manuals/glibc-2.2.3/html_chapter...
Re: Serving a high-performance blog solely from memory, using Rust
#29I admire the OP's ability to use their blog as a rapid prototyping platform that is constantly growing and changing. Over engineering on a personal project like this is the whole point! Very cool. I am too much of an OCD perfectionist and don't have the guts to ship this often.
I have CDO too but I work around it by sheer trolling with infrastructure, like my hacked up to hell CDN: https://xeiaso.net/blog/xedn
Re: Serving a high-performance blog solely from memory, using Rust
#30I would have liked to see the actual results from this comparison: "I compared my site to Nginx, openresty, tengine, Apache, Go's standard library, Warp in Rust, Axum in Rust, and finally a Go standard library HTTP server that had the site data compiled into ram."