News for hackers. Stuff that matters.
Re:The beauty of CGI and simple design by roywashere on Saturday January 07, 2023 @05:39AM (#34286917)
I find it kind of interesting that people frowned upon CGI because it was not efficient. And yet here we are using lambas on AWS like it’s the best invention ever
Re:The beauty of CGI and simple design by pjmlp on Saturday January 07, 2023 @05:41AM (#34286921)
That is why with experience one learns to ignore fashion trends until they eventually either become unavoidable, or fade away from conference talks.
Re:The beauty of CGI and simple design by agumonkey on Saturday January 07, 2023 @07:38AM (#34287514)
I wonder what's the best way: try to extract profit from the fads (cynic) or isolate..
Re:The beauty of CGI and simple design by SoapSeller on Saturday January 07, 2023 @05:46AM (#34286948)
Doesn't lambdas are more efficient than CGI due to ability to keep the runtime env running (JIT cache and all)?
Re:The beauty of CGI and simple design by speedgoose on Saturday January 07, 2023 @05:54AM (#34286983)
Yes it’s like FastCGI. But expensive.
Re:The beauty of CGI and simple design by scotty79 on Saturday January 07, 2023 @07:23AM (#34287415)
Funny how the word "expensive" when referring to code execution might today mean actual money, not just memory or time.
Re:The beauty of CGI and simple design by saurik on Saturday January 07, 2023 @05:50AM (#34286964)
Yeah: AWS Lambda feels a lot more like the things that came after CGI, not CGI.
Re:The beauty of CGI and simple design by squarefoot on Saturday January 07, 2023 @05:50AM (#34286961)
No web dev here, but if memory serves, the main concerns about CGI were about safety, not performance or efficiency. If that's the case, I wonder if new more safe languages could make its use viable again.
Re:The beauty of CGI and simple design by yakubin on Saturday January 07, 2023 @05:55AM (#34286994)
With people reaching for kqueue, epoll and io_uring to handle the C10K problem it seems that spawning processes wouldn’t be a great idea, with the latency and memory overhead of spawning itself, as well as the meagre limits of the number of concurrent processes in a system.
Re:The beauty of CGI and simple design by mrweasel on Saturday January 07, 2023 @07:24AM (#34287418)
One issue was that people configured CGI wrong. You had executable scripts that had free range on the entire filesystem. Ideally you'd need to limit the cgi-scripts to a chroot, but that made it difficult to use Perl, Python and PHP. OpenBSD shipped/ships a chrooted Perl for use with CGI, but other operating systems just left that bit as an exercise to the programmer.

More modern languages like Go or Rust provides a lot of safety and is pretty easy to statically compile, so it's easily chrooted. It would however be weird to do a CGI program in Go, because that language already have a really good build in webserver and more powerful/easily accessible features for interacting with requests compared to what CGI provides.

Re:The beauty of CGI and simple design by sgbeal on Saturday January 07, 2023 @07:51AM (#34287586)
> It would however be weird to do a CGI program in Go, because that language already have a really good build in webserver and more powerful/easily accessible features for interacting with requests compared to what CGI provides.

Noting that not everyone has the ability to run standalone servers on their web hoster. Shared hosters generally enable CGIs but cannot support per-user standalone servers, in particular not on common ports like 80 or 443.

Re:The beauty of CGI and simple design by ptx on Saturday January 07, 2023 @07:28AM (#34287444)
What safety concerns are you referring to? CGI scripts often had issues with SQL injection and shell command injection, but that was because of badly designed (or poorly used) libraries and unrelated to CGI itself. Or if CGI programs were written in C (as a result of performance concerns) those would of course have the usual memory safety issues of C programs.
Re:The beauty of CGI and simple design by diocles on Saturday January 07, 2023 @08:14AM (#34287704)
(Not the parent but) one cool CGI-specific problem that always comes to mind is HTTPoxy:

https://www.ionos.co.uk/digitalguide/server/configuration/ht...

You could write this off as a library implementation problem, but it comes about because of unfortunate mapping of HTTP parameters to well-known environment variables in CGI, and has tripped up multiple library authors.

Re:The beauty of CGI and simple design by ilyt on Saturday January 07, 2023 @11:45AM (#34289761)
Usually poor ops hygiene, same really as PHP problems:

* Code runs as web server user * Code is deployed as web server user, because web monkey doesn't understand unix permission (or alternatively chmod 777 everything for same effect) * Code gets hacked, attacker can modify any file so they just leave backdoor in code

If you deploy code as different user attacker can still of course steal all the data but at the very least they can't modify the code that is running.

On top of that, a lot of poor security practices when it comes to qouting stuff. Perl had kinda interesting feature regarding that where in special mode (recommended for apps dealing with untrusted inputs) the variable was considered tainted [1] till something "cleaned" it by passing it thru regexp. So say taking argument directly from environment (so headers for web) or stdin and passing it with no processing to system() would trigger it.

* [1] https://perldoc.perl.org/perlsec

Re:The beauty of CGI and simple design by geenat on Saturday January 07, 2023 @05:52AM (#34286974)
lambda = highest efficiency path for your money into bezos' bank account.
Re:The beauty of CGI and simple design by revskill on Saturday January 07, 2023 @05:54AM (#34286988)
Because people lack enough time, but have enough money.
Re:The beauty of CGI and simple design by Existenceblinks on Saturday January 07, 2023 @06:36AM (#34287166)
Start time yeah. They seem to have a lot of time later trying to come with something more time efficient in long term.
Re:The beauty of CGI and simple design by ilyt on Saturday January 07, 2023 @11:39AM (#34289691)
Yet they always find a time to wank with some new tech stack instead of just using what worked before just fine...
Re:The beauty of CGI and simple design by ojkelly on Saturday January 07, 2023 @05:54AM (#34286982)
Lambdas are awesome because they enable event driven computing without needing to worry about scaling.

There’s other ways to get that model, but lambda makes it pretty easy.

Re:The beauty of CGI and simple design by WJW on Saturday January 07, 2023 @05:58AM (#34287007)
If there is another request "in the queue", a lambda that is done with a request will just pick that one up instead of closing down and letting a new lambda spin up to deal with the next request. So as soon as you have enough traffic that you have $CONCURRENCY_LIMIT amount of lambdas running (otherwise you would never build up a queue of course), the execution model of lambdas approximates fastCGI much more than regular CGI.

Personally I think the enthusiasm for lambdas stems from several things:

- A (legitimate) interest in outsourcing non-essential things like server maintenance to somewhere else with more ops experience. This frees up the devs to work on business logic instead of worrying about backups and log rotations.

- Some people are REALLY enthusiastic about the whole scale-down-to-zero thing. I personally think that that is somewhat shortsighted, since that means trading (expensive!) engineering time to save a few 100 USD per month on your AWS bill. Sometimes it is definitely worth it to

- Some people are very enthusiastic about how you can instantly get to "web scale" with lambdas by just putting a very large max concurrency number. That is somewhat true, but massive overkill for the vast majority of companies. It's "engineer it like Google" syndrome but with Amazon instead.