Before nginx was a thing, I worked with a guy who forked apache httpd and wrote this blog in C, like, literally embedded html and css inside the server, so when he made a tpyo or was adding another post he had to recompile the source code. The performance was out of this world.
Yes
Submitted 1 year ago by mac@programming.dev to programmer_humor@programming.dev
https://programming.dev/pictrs/image/b2e4aaf7-c773-4f45-a1e6-287199766d42.jpeg
Comments
agilob@programming.dev 1 year ago
Schmeckinger@feddit.de 1 year ago
There are a lot of solutions like that in rust.
vox@sopuli.xyz 1 year ago
but not the whole fucking prerendered static page
PieMePlenty@lemmy.world 1 year ago
Does a file lookup really take that long? Id say the trick was to have just plain old html with no bloat and you’re golden.
agilob@programming.dev 1 year ago
Blog content was stored in memory and it was served with zero-copy to the socket, so yea, it’s way faster. It was before times of php-fpm and opcache that we’re using now. Back then things were deployed and communicated using tcp sockets (tcp to rails, django or php) or reading from a disk, when the best HDDs were 5600rpm, but rare to find on shared hosting.
MeanEYE@lemmy.world 1 year ago
The answer is no. The more file is used the longer it sits in kernel filesystem cache. Getting file from cache versus having it in process memory is few function calls away all of which takes few microseconds. Which is negligible in comparison to network latency and other small issues that might be present in the code.
On few of our services we decided to store client configuration in JSON files on purpose instead of running with some sort of database storage. Accessing config is insanely fast and kernel makes sure that file is cached so when reading the file you always get fast and latest version. That service is currently handling around 100k requests a day, but we’ve had peaks in past that went up to almost a million requests a day.
Besides when it comes to human interaction and web sites you only need to get first contentful paint within one second. Anything above 1.5s will feel sluggish, but below 1s, it feels instant. That gives you on average around 800ms to send data back. Plenty of time unless you have a dependency nightmare and parse everything all the time.
justJanne@startrek.website 1 year ago
Ah, you met fefe.
sebsch@discuss.tchncs.de 1 year ago
Fefe used an LDAP server as backend, not Apache
bazsalanszky@lemmy.toldi.eu 1 year ago
This reminds me of one of my older projects. I wanted to learn more about network communications, so I started working on a simple P2P chat app. It wasn’t anything fancy, but I really enjoyed working on it. One challenge I faced was that, at the time, I didn’t know how to listen for user input while handling network communication simultaneously. So, after I had managed to get multiple TCP sockets working on one thread, I thought, why not open another socket for HTTP communication? That way, I could incorporate a fancy web UI instead of just a CLI interface.
So, I wrote a simple HTTP server, which, in hindsight, might not have been necessary.
MeanEYE@lemmy.world 1 year ago
Nothing good old cache can’t solve. Compile JS and CSS. Bundle CSS with main HTML file and send it in batches since HTTP2 supports chunkifying your output. HTTP prefers one big stream over multiple smaller anyway. So that guy was only inviting trouble for himself.
agilob@programming.dev 1 year ago
You’re telling me about compiling JS, to my story that is so old… I had to check. and yes, JS existed back then. HTTP2? Wasn’t even planned. This was still when IRC communities weren’t sure if LAMP is Perl or PHP because both were equally popular ;)
fireflash38@lemmy.world 1 year ago
What if, get this, we put the bash scripts in yaml. And then put it in kubernetes.
PupBiru@kbin.social 1 year ago
well now you’re just describing ansible
Vash63@lemmy.world 1 year ago
Very, very bad Ansible.
nxdefiant@startrek.website 1 year ago
Have you considered embedding python in those bash scripts? I have done this, and it is glorious.
Socsa@sh.itjust.works 1 year ago
This is false, you also need vim and tmux
Rin@lemm.ee 1 year ago
Idk about you but I use echo and sed to edit my files.
clearleaf@lemmy.world 1 year ago
FauxPseudo@lemmy.world 1 year ago
I’m currently trying to relearn all my advanced bash in python.
aes@lemm.ee 1 year ago
i already learned how to use my operating system, now you’re telling me I have to learn a new library that does the exact same shit?
bort@feddit.de 1 year ago
no, you’ll also have to learns each libraries special quirks for your OS
tdawg@lemmy.world 1 year ago
Just for fun or do you have a specific thing you feel would be better in python?
FauxPseudo@lemmy.world 1 year ago
Certain things I want to do will be easier in python and will be more portable. But bash is my home.
MonkderZweite@feddit.ch 1 year ago
Just don’t call it with ‘!#/bin/sh’. Because that’s POSIX shell, not bash.
philm@programming.dev 1 year ago
but effectively it’s bash, I think
/bin/sh
is a symlink to bash on every system I know of…MonkderZweite@feddit.ch 1 year ago
Still don’t do this. If you use bash specific syntax with this head, that’s a bashism and causes issues with people using zsh for example. Or with Debian/*buntu, who use dash as init shell.
JackbyDev@programming.dev 1 year ago
No no no no no, do not believe this you will shoot yourself in the foot.
Beginning with DebianSqueeze, Debian uses Dash as the target of the /bin/sh symlink. Dash lacks many of the features one would expect in an interactive shell, making it faster and more memory efficient than Bash.
From DebianSqueeze to DebianBullseye, it was possible to select bash as the target of the /bin/sh symlink (by running dpkg-reconfigure dash). As of DebianBookworm, this is no longer supported.
SurpriseWaterfall@sopuli.xyz 1 year ago
It is a symlink, but bash will automatically enable posix compliance mode if you use it. So any bash specific features will bomb out unless you explicitly reset it in the script.
UNWILLING_PARTICIPANT@sh.itjust.works 1 year ago
Wut that is not even the case for Ubuntu. You’re probably thinking of
dash
example:sh -c '[[ true ]] && echo ya' # sh: 1: [[: not found bash -c '[[ true ]] && echo ya' # ya
callyral@pawb.social 1 year ago
i thought most unix-like systems had it symlinked to a shell like
dash
. it’s what i have on my system.i use
#!/bin/sh
for posix scripts and#!/usr/bin/env bash
for bash scripts.#!/bin/sh
works for posix scripts since even if it’s symlinked to bash, bash still supports posix features.Aatube@kbin.social 1 year ago
macOS
Debian
Ubuntu
MeanEYE@lemmy.world 1 year ago
I feel like this with Python these days.
DriftinGrifter@lemmy.blahaj.zone 1 year ago
Me when micropython isn’t fast enough to give my microcontroller complex real-time responses
Maoo@hexbear.net 1 year ago
You’re not at scale unless you’re deploying OpenStack to run a WordPress site.
msage@programming.dev 1 year ago
Which is hilarious since PHP scales incredibly well on its own.
Maoo@hexbear.net 1 year ago
Regrettably, it does do that
moonpiedumplings@programming.dev 11 months ago
No I swear, I was gonna do more than that.
Maybe like, a static site as well. And a backup server. Y’know, things you need openstack for.
looks away guiltily
SpaceNoodle@lemmy.world 1 year ago
Never sed when you can bash.
cyborganism@lemmy.ca 1 year ago
All you need are Bash scripts with chroot and cgroups and some ssh access.
einfach_orangensaft@feddit.de 1 year ago
i feel this
onlinepersona@programming.dev 11 months ago
The dude on the right is some neckbeard who yells “RTFM” and “i use Arch btw ;)” IRL.
asw13c@programming.dev 1 year ago
wow
asw13c@programming.dev 1 year ago
d
wolo@lemmy.blahaj.zone 1 year ago
my website’s backend is made with bash, it calls make for every request and it probably has hundreds remote arbitrary code execution bugs that will get me pwned someday, it’s great
camr_on@lemmy.world 1 year ago
For my own sanity, I choose to believe you’re lying
PupBiru@kbin.social 1 year ago
who hurt you?
agent_flounder@lemmy.world 1 year ago
These wounds appear to be self-inflicted.
wolo@lemmy.blahaj.zone 1 year ago
i thought it was neat how php lets you write your website’s logic with the same directory tree pattern that clients consume it from, but i didn’t want to learn php so i made my own, worse version
Fashim@lemmy.world 1 year ago
I pity the hacker who ends up in your system
agilob@programming.dev 1 year ago
You live like this?
wolo@lemmy.blahaj.zone 1 year ago
I’ve taken some precautions, it’s running in a container as an unprivileged user and the only writable mount is the directory where make writes rendered pages, but i probably should move it into a vm if i want to be completely safe lol
bdonvr@thelemmy.club 1 year ago
I designed a chip architecture that runs bash code on silicon.
I reimplemented x86 assembly in purely bash script.
SpaceNoodle@lemmy.world 1 year ago
Seek help.
Belzebubulubu@mujico.org 1 year ago
lord forgive me for I have sinned.
gandalf_der_12te@feddit.de 11 months ago
you do realize that you can just use Apache instead of writing yournown rudt prigram for this, as this is more or less the CGI standard?
wolo@lemmy.blahaj.zone 11 months ago
I know about the CGI standard, but mine does things a little differently (executable files don’t just render pages but also handle logging, access control, etc. when put in special positions within a directory), so I still think it was worth the afternoon i spent making it.