DEV Community

Cover image for Building Buntastic: A Fast, High-Performance Static Site Server (OSS)
Peter Mbanugo
Peter Mbanugo

Posted on • Edited on • Originally published at devopsforjavascript.dev

Building Buntastic: A Fast, High-Performance Static Site Server (OSS)

Static sites are fast, secure, and easy to manage. The JAMStack movement help made it popular (after SPAs) and static site builders like Hugo and Eleventy are making it simple to build websites in this manner. I dare not mention Astro because it's the new kid making building static sites cooler than ever.

There are plenty of options to host static sites. Like;

  • Using AWS S3 and CloudFront
  • Using static site hosting providers like Netlify or even hosting with GitHub Pages.

These options are good but as with most things, there are tradeoffs. The issue with most of those options is that you have little or control of the server, which makes things like configuring cache-control headers impossible. Some features might be locked in expensive plans, or you run into limitations on the number of domains or sites you can host. Many of them also limit the number of requests your site can handle per month.

What if you are able to host your static websites (or your client's) by yourself, without restrictions and in a cost-effective manner?

That's why Buntastic.

What is Buntastic?

Buntastic is a high-performance static site server that's designed to be flexible and easy to use. It's built to run on Bun(a fast and modern JavaScript runtime) and it uses Bun's S3 API. It can use any S3-compatible object storage to store the site files. However, I'd recommend you use Tigris because it can cache objects globally, making it faster for you to access them from anywhere in the world. Think of it like AWS S3 and CloudFront combined, but in this case you don't have to pay extra for global cache or worry about setting up an extra tool.

If you want to deploy in multiple regions so that your users can have lower latency, I'd recommend Fly.io because scaling to zero and multi-region deployment is as simple as running a single command.

This is what we get when we combine the web server performance of Bun, Tigris's Global Object Storage, and multi-region deployment on Fly.io:

  • Serve multiple static websites from one application
  • Smart path handling with automatic index.html resolution
  • Globally fast and automatic TLS certificates (if using Fly)
  • Easy configuration through JSON
  • Brotli & zstd compression support
  • Built-in monitoring with Grafana dashboard on Fly
  • Built on Bun's native S3 client and web server, thereby benefiting from Bun's fast performance
  • It uses zero dependency and can run on a single machine with 256MB RAM

The Speed Factor 🚀

Here's a load test on a shared VM with 256MB RAM, 1 vCPU, deployed to the Stockholm (Sweden) region on fly.io. Buntastic is super-fast 🔥

Load testing demonstration as GIF

Most responses come in under 100ms, for a response that weighs 6KiB. That's fast! Here's a still image so you can see the numbers clearly:

Load testing image results

More About The Tech Stack âš¡

By now you know that the secret sauce is a combination of modern tech that works together beautifully:

Bun's Native Powers

Built on Bun's native S3 client and web server, we're getting incredible performance benefits right out of the box. Zero dependencies mean less overhead and faster execution.

HTTP/3 + Smart Compression

Here's what you get if you deploy to Fly:

  • HTTP/3 support for modern web performance
  • Brotli & zstd compression keeping things lean
  • automatic TLS certificates for secure connections
  • Fly.io's global compute for fast and reliable global distribution

Globally Distributed Object Storage

  • Tigris provides global caching out of the box
  • Objects cached closer to users = faster subsequent requests

Why You Might Need This 🤔

If you're a design/dev agency, freelancer, or just someone managing multiple sites, here's why Buntastic might be your new best friend:

  1. Simplified Management: One server, multiple sites, each with its own domain
  2. Cost Efficiency:
    • Can run on minimal resources (256MB RAM!)
    • Scale to zero when idle
    • Volume-based pricing on Fly.io
  3. Complete Control:
    • Configure redirect/rewrite rules
    • Add custom middleware
    • Set up authentication per domain if you want to share it with clients.

This might not be the cheapest option if you are targeting hosting just one website. It can be a really affordable option for running multiple websites, with the control and flexibility that you won't get otherwise.

I imagine that using volume-based pricing and auto-scale to zero on Fly, you can get a lot with just a few bucks a month. Currently, the cheapest machine with 256MB RAM is around $3.xx/month on a volume license (at least the US regions). If your customers are in the US, and you serve infrequest requests, you can get away with a lot of sites for a few bucks a month.

FAQs

"Why not just use traditional static hosting?"

Traditional hosting is fine, but Buntastic gives you more control and flexibility. Want to add authentication to specific routes? Need custom redirect rules? Want to serve content to specific users?

You can do all that and more.

"Is it more expensive to self-host?"

It depends on your scale. For a single low-traffic site, traditional hosting might be cheaper. But if you're managing many sites or dealing with higher traffic, the combination of Tigris and Fly's volume-based pricing can actually save you money or give you more speed.

"Can I use any S3-compatible storage?"

Absolutely! While we recommend Tigris for its global caching benefits, any S3-compatible storage will work just fine.

What's Next?

Check out the code and set up instructions on GitHub. Please DON'T forget to star the repo if you find it useful!

This is just the beginning and here's what I plan to add to it soon:

  • CLI for simplified site uploads
  • 103 Early Hints support
  • More caching semantics
  • Multi-core configuration
  • Bot request blocking (I wonder if this makes sense to add or leave to CDNs)

There you go. Self-hosting static sites on your own terms. Buntastic! 🚀

Top comments (0)