💾 Archived View for tilde.pink › ~slondr › small-web-on-small-servers.gmi captured on 2024-03-21 at 15:46:59. Gemini links have been rewritten to link to archived content

View Raw

More Information

⬅️ Previous capture (2023-01-29)

-=-=-=-=-=-=-

Running small-web servers on small servers

I recently bought a small single-board computer to set up Pi Hole, only to find that the 256 MB of on-board memory was insufficient to run the admin interface without constant crashes.

The computer does not have any video output, but does have ethernet. Its CPU is weak, but quad-core. Power consumption is very low. I was thinking about how feasible it would be to run a smallweb server on this device, to give it new purpose after a web server proved too expensive.

I started benchmarking the Gemini server I wrote but haven't yet set up in a production environment, egalayxd. The server is highly concurrent and will use all available cores to reach peak efficiency, so I was worried it may use a lot of memory especially when a lot of requests come in at once.

egalaxyd

Booting up the server without serving anything yet, egalaxyd consumes 46 MB of memory and no CPU. That's a decent chunk of the available system memory on my single-board computer, but not too bad. To test it, I issued 400 requests for index.gmi from another machine (egalaxyd does not yet implement its own cache system, but I'd expect the file to be cached by the Linux kernel after the first full read). To my surprise, memory usage only increased to 47 MB!

Then I issued 4096 requests for random URLs, some valid but most invalid, via GNU parallel. Throughout and after the request swarm, memory usage hit 48 MB and then went back down to 46 MB. Wow!

I wasn't even paying attention to keeping memory usage low when designing this server, but I'm impressesd enough with the results here that I'm ready to dive head first into setting it up permanently on my single-board computer. I'll probably want to flash a new OS to the SD card and set up a unique user for the Gemini server with strict permissions, because I haven't yet implemented a directory traversal mitigation system in egalaxyd. But the idea of moving this gemlog off of tilde.pink and onto hardware I own using software I wrote is pretty exciting!

As an aside: A note on MCUs

I've seen people talk about serving Gemini content via microcontrollers, either over FreeRTOS or boards with built-in wifi. I think I'll stay away from that world for now, because you usually have to do silly stuff to get your server to think you have a real file system, and adding new content often isn't straightforward. Also, my gemini server is written in Elixir, and I really doubt that I can acheive the concurrent performance I have with egalaxyd on an MCU without sacrificing the extensibility of the Erlang platform. Oh well, maybe one day...