13 ms·
BCHS stack – BSD, C, httpd, SQLite
- HeckFeck 5y ago> Wasn't this site once funnier? > Yes. But some folks confused humour with levity. Time to fire up the Wayback machine ;)
- tyingq 5y agoI guess forking a cgi-bin program for every request keeps memory leaks down.
- LAC-Tech 5y agoNot an expert, but I think kcgi uses fastcgi under the hood. https://kristaps.bsd.lv/kcgi/ https://kristaps.bsd.lv/kcgi/
- mistralefob 5y agoWe write backend in C++ with http server builtin, so there is 1 forever running thread for all the requests and zero initialization time: http://fintank.ru:8080/s/test http://fintank.ru:8080/s/test
- avmich 5y agoEnjoyed doing FastCGI with this framework, but simple examples don't present realistic complexity. Struggled with ways to create a small web app while maintaining simplicity similar to the examples provided (such as here - https://learnbchs.org/easy.html https://learnbchs.org/easy.html ) even though semantics wasn't that different (present a form, after accepting data make a request, present a transformed result).
- jvanderbot 5y agoI've been ``statically'' compiling my php scripts to HTML. It's marvelous. My build system is a makefile, and it feels like I'm parodying myself and the entire industry. Is this the same?
- Cyberdog 5y agoIt could be, but the presumption is that you're not building something that could just be compiled down to a static site at the end.
- pyuser583 5y agoDoes anyone actually use this?
- numlock86 5y agoWhile I think quite a few people use this, I question the actual benefits. People often argue with performance, but unless you spend a lot of work into doing things right, the general "C backend" won't outperform even simple things like nodejs ... at least once you reach the realm of ten-thousands of requests per second coupled with more than just a static page, "hello world" and a for-loop. Same goes for the "DBMS" part of things, being the bottleneck for the majority of real world applications anyway. I think the best use case would be some static content delivery coupled with a few dynamic pages and APIs backed up by SQLite here and there ... Some references would be cool I guess. Anyone?
- 10000truths 5y agoYou can easily serve 10000 static requests/second per core on a modern server grade CPU over TLS with nginx, which is written in C. Slap node.js and express on top and you might dip to something like half of that. But the real win with using C (or rather, using direct syscalls) comes from how much of that throughput you can retain while serving dynamic content. At least on Linux, performantly serving a static file would have a syscall flow similar to the following: file -> splice -> pipe -> splice -> kTLS socket The performance increase comes from copying the file to the socket without any detouring of the data via userspace. This can easily be adapted for the case where you need to inject portions of that file with dynamically retrieved content, by using offset fields in the splice call from the file being served, and manually writing to the pipe to inject the dynamic content. You cannot easily replicate this construct in any other dynamic-content server framework I know of - you have to do it manually in C (or any language that allows you to directly invoke system calls).
- LAC-Tech 5y agoAny one use open BSD to host servers? Last time I checked httpd didn't support http/2.
- dangerface 5y agoI use freebsd and nginx in production its a great system super stable
- turminal 5y ago> Last time I checked httpd didn't support http/2 Some would argue that's a feature.
- mrweasel 5y agoFor most stuff http/2 doesn’t matter. I guess at some point they’ll want to add support for http/2, for now it not important unless your a fairly large site.
- creshal 5y agoDon't Google et al. already penalize your search ranking for not offering http/2?
- 0x10c0fe11ce 5y agoI’ve been running caddy on a FreeBSD jail proxying to another one running uwsgi+python3 and it has been a breath of fresh air. Though, it comes with a somewhat steep learning curve. But, in the end you can throw away that pesky search foo hat, and have some deserved peace of mind.
- Cyberdog 5y agoI host my personal site on OpenBSD and its built-in httpd, though in its current incarnation it's just serving static HTML. No, no HTTP/2, but if I cared about that I could install Nginx and use that instead. httpd's config syntax is mostly sane and error messages are mostly legible, and that it's written by OpenBSD's core devs inspires confidence. I recommend that system admins at least give it a try, especially if they've already decided to use OpenBSD. It can't do everything but I think it does enough to meet the needs of 80% of the web's sites.
- creshal 5y agoReplace C/httpd with golang and you get a stack that's fairly decent.
- nix23 5y agoReplace golang with elixir and phoenix, and you have a fairly reliable stack ;)
- _ph_ 5y agoI don't know why you are downvoted - this is one of the tasks, where Go is just a better C. I do like the approach of this stack, having a slim stack with a staticly compiled web page. But switching to Go gives the developer much more safety and quicker development for the custom part. C is great for developing components like sqlite - which are well tested and only slowly evolving. But the quick changing custom code in a web site, there Go shines.
- ratorx 5y agoI can recommend Go for this too. I use it for small APIs. Go has really easy cross compiling as well, so deploying from Linux to OpenBSD is really simple. I still use httpd as the proxy but use compiled Go executables for CGI.
- mrweasel 5y agoLike real CGI, as an executable in cgi-bin?
- adrianN 5y agoWriting web-facing code in C in 2021 is seldomly a good idea, even if it runs on OpenBSD in a jail.
- sobakistodor 5y agoIt is good idea in terms of long-term money spendings: if you already have good C++ HTTP framework, you spend less cpu/memory and can make web-service\site that can live forever for 0.00001 dollars a month. Of if you planning to serve lost of requests AND want users to feel low latency responce, you have no options: Rust, Go, C++, maybe something else. Main fight must occur on the "C++ vs Rust" scene, but C++ certainly wont die in another 20 yers, so you happy using it for long-term projects.
- masklinn 5y ago> Of if you planning to serve lost of requests AND want users to feel low latency responce, you have no options: Rust, Go, C++, maybe something else. That sounds like a lot of options. While I don't exactly like Go, that's very much the sort of things it was designed for, "stdlib-only" go will give you everything you need with pretty much guaranteed safety. > Main fight must occur on the "C++ vs Rust" scene, but C++ certainly wont die in another 20 yers, so you happy using it for long-term projects. The concern is less the death of C++ and more exposing C over the web, which exponentially increases the damage of any mistake you make (likewise C++ though likely with a lower exponent).
- sobakistodor 5y agoAs I remember, Go was "invented" to allow writing SMALL projects, where people previously used Bash/C/Perl. Like all these small command-line utilities and scripts to solve Site-Reliability-Engineer-tasks or DevOps-tasks. Using Go in projects larger than "multithreaded custom-binary-format to CSV converter" or "daemon watching sensors and inserting ROWS to some DB" is not very good. Big thing about GO is lots of libs available for everything (but in that view Python is better).
- rambambram 5y agoStill very happy with my CHAMP-stack (CSS, HTML, Apache, MySQL and PHP).
- kristapsdz 5y agoTo answer questions so far (I'm the author of learnbhcs): yes, folks use BSD to host servers (if you want HTTP/2, there's nginx, etc.); kcgi interfaces with either CGI or FastCGI depending upon what the caller wants; yes, folks use this.
- dangerface 5y agoDoing web development in c and getting that sweet performance boost is very tempting but the time it takes to develop even a simple website is just not worth it. I would rather spend a few pound extra on servers and goto the cinema than the hours of developer time it would take to build PHP sites in C++
- sobakistodor 5y agoYou just using some "framework" to develop C++ apps. This framework should give you place for you DO_FUNCTION() and everything else is implemented: 80-port-listening, DB-interaction and so on.
- Cthulhu_ 5y agoYou can get the same performance boost without the footgun of C if you use e.g. Go, I've done so for a while now and I'm quite enamoured by it. Possible downside is that it ships with a runtime, so binaries are at least 10MB (before optimizing for size). That said, you mention PHP, I wonder how PHP running in HHVM compares to a more bare metal solution (or regular interpreted PHP).
- fleetfox 5y agoToday there is little reason to use HHVM since modern PHP comes with JIT
- Abishek_Muthian 5y agoI agree, Anyone who runs a Go web service would probably concur. Switching to Go for my web applications has not only enabled me to make faster releases but has also increased the capital efficiency from the cost savings for HW resources(Because of efficiency).
- Asdrubalini 5y agoUsing a ARNP stack here (ArchLinux, Rust, nginx, PostgreSQL). It works great.
- mahkoh 5y agoI'm running a moderately popular website with this stack on a $5 VPS. More precisely I'm running an ARNPCoW (Cloudflare or WireGuard) stack. That is, an ARNP stack that serves https from behind Cloudflare and drops packets that don't come from one of Cloudflare's advertised IPs unless they are from a WireGuard connection.
- imwillofficial 5y agoTrying to make the term BCHS a thing just isn’t going to happen.
- bqmjjx0kac 5y agoGretchen, stop trying to make fetch() happen! Seriously, how are you supposed to pronounce BCHS?
- secondcoming 5y agoOur core business is served by an apache module written in C++. I don't particularly like apache but writing an HTTP server from scratch is deceptively hard, especially in C. We took a quick look at nginx but found it hard to figure out. We also use microhttpd to give us an entrypoint where we can pull stats from small programs.
- p4bl0 5y agoI totally get the geeky appeal of such a web development stack (a few years ago I could have chosen that for my personal web page, for fun). But in practice I doubt that it ends up a win in terms of security, maintainability, and development time.
- Cthulhu_ 5y agoMakes me wonder what my stack would be abbreviated to. LAGS? (linux, apache, go, sqlite? Apache is optional. As is Linux.)
- floor_ 5y agoCheck out the markup generation of this custom http server: https://caseymuratori.com/blog_0034 https://caseymuratori.com/blog_0034
- palerdot 5y agoJust insert an `A` (maybe Assembly) after B, so that this becomes BACHS. Has a nice ring to it. Maybe advertised as BACHS - a truly baroque stack