4 ms·
> A real Python CGI would take longer to start because it has more things to import, but even then it's not necessarily terribly slow. That's where the author
by nwellnhof 3y ago
> A real Python CGI would take longer to start because it has more things to import, but even then it's not necessarily terribly slow.
That's where the author is wrong. Complex Python, Ruby or Perl scripts can easily take several hundred milliseconds just to import required modules.
- bee_rider 3y ago“not necessarily terribly” is a little weasel-wordy, but it does, I think, give them enough space to consider hundreds of milliseconds as not a big deal. Edit: see the responses for why “not necessarily terrible” is kind of annoying, now I have a comment that says there exists a use case where they care about it, and there exists one where they don’t.
- j45 3y agoIt might not be consistent to compare the entire request lifecycle instead of the original comment in only firing up.
- arp242 3y agoHundreds of milliseconds can be "not a big deal" depending on what your program is, how often it's run, etc. The last time I used CGI was for the "sign up to my newsletter" on my website; the endpoint for that would lock a file, append the email from the form, and close it. Even if that takes a second (which it didn't, more like 50ms) then ... that would actually be fine for this particular use case of a small newsletter. Of course for many other things it would be horrible. I think "not necessarily terrible" is a reasonable way to phrase things.
- surfingdino 3y agoDepends on the load levels or payment schedule. If we are talking about AWS Lambdas, hundreds of milliseconds are costing real money, which is why I write my Lambdas in Go instead of Python. That way we keep their exec time under 100ms which became unachievable with Python for the kind of code we're running. I love Python, but I don't love it enough to pay double or quadruple of what I pay for running Go code.
- acdha 3y agoYou’re right about the time is money dynamic but Lambda won’t hit this particular case because your imports will happen before the Lambda function starts receiving requests. I use that for things like retrieving SSM parameters and other setup work involving network requests.
- acdha 3y agoThat’s the “not necessarily” part - Python takes under 20ms to start and import a few modules. If your needs are modest, there’s a solid argument for simplicity there. If not, it is not a huge lift to move from that to a persistent server model where you could do big imports once, either using the stdlib HTTP server or switching to Fast CGI.