Live data from Hacker News

Show HN: Hosting my website using my C web server

github.com

31–40 of 160 posts

Re: Show HN: Hosting my website using my C web server

#31
post #26

Finally a website that doesn't crash when it shows up on the front page

Any site with a CDN in front of it can do that. Don’t get me wrong this is an awesome project but if you really care about this kind of thing in a production scenario and you’re serving mostly static content… just use a CDN. It’ll pretty much always outperform just about anything you write. It’s just boring.

Any site that consists of static files served by a professional-grade web server like nginx on a small VPS can also trivially do that.

Re: Show HN: Hosting my website using my C web server

#32
post #26

Finally a website that doesn't crash when it shows up on the front page

Any site with a CDN in front of it can do that. Don’t get me wrong this is an awesome project but if you really care about this kind of thing in a production scenario and you’re serving mostly static content… just use a CDN. It’ll pretty much always outperform just about anything you write. It’s just boring.

If you're hosting static data, shouldn't HTTP cache flags be enough in most cases? Read-only cacheable data shouldn't be toppling even a modest server. Even without an explicit CDN, various nodes along the chain will be caching it.

(though I confess it's been some years since I've worked in this area)

Re: Show HN: Hosting my website using my C web server

#35
post #26

Finally a website that doesn't crash when it shows up on the front page

Any site with a CDN in front of it can do that. Don’t get me wrong this is an awesome project but if you really care about this kind of thing in a production scenario and you’re serving mostly static content… just use a CDN. It’ll pretty much always outperform just about anything you write. It’s just boring.

This sort of trivializes the effort and the fun of a project like this, doesn't it? Yes, you'll want to put all of your ducks in a row when you go to full production and you've reached full virality and your project is taking 5 million RPS globally and offloading all of that onto a CDN and making sure your clients requests are well respected in terms of cache control and making it secure and putting requests through a waf and and and and and. Yes we know. Lighten up. The comment you're replying to was meant to be lighthearted.

Re: Show HN: Hosting my website using my C web server

#37
post #26

Earlier quoted context omitted.

Any site with a CDN in front of it can do that. Don’t get me wrong this is an awesome project but if you really care about this kind of thing in a production scenario and you’re serving mostly static content… just use a CDN. It’ll pretty much always outperform just about anything you write. It’s just boring.

If you're hosting static data, shouldn't HTTP cache flags be enough in most cases? Read-only cacheable data shouldn't be toppling even a modest server. Even without an explicit CDN, various nodes along the chain will be caching it. (though I confess it's been some years since I've worked in this area)

That’s not the case these days. Due to TLS, there is very little catching in between you and the server you’re hitting.

Re: Show HN: Hosting my website using my C web server

#38

Only 3.4k of C code for a full http and https server? I honestly thought you would need a lot more for it to be fully compliant with the spec.

It feels about right to me. OpenBSD's httpd(8) [1] currently clocks in at just below 15,000 lines when you include its documentation. Take away a few features, make a few assumptions , and I would not be surprised we are in the 5,000 lines territory like this project.

    $ wc -l *
        31 Makefile
       910 config.c
       314 control.c
        34 css.h.in
       257 http.h
       100 httpd.8
      1262 httpd.c
       882 httpd.conf.5
       843 httpd.h
        19 js.h.in
       218 log.c
       319 logger.c
      2563 parse.y
       309 patterns.7
       713 patterns.c
        46 patterns.h
       829 proc.c
      1484 server.c
       849 server_fcgi.c
       826 server_file.c
      1997 server_http.c
        10 toheader.sed
     14815 total
[1]: https://man.openbsd.org/httpd.8

Re: Show HN: Hosting my website using my C web server

#40

Only 3.4k of C code for a full http and https server? I honestly thought you would need a lot more for it to be fully compliant with the spec.

I wrote a simple embedded C webserver to provide a liveview of data acquisition for one of my experiments that weighs in at <250LOC. Ok, I wouldn't put it on the public internet, and it only implements a small fraction of HTTP/1.1, but it works and only requires mallocing at initialization...
Post reply on HN