5 ms·
> Ever since I wrote about the whole Python/Gunicorn/Gevent mess a couple of months back, people have been asking me "if not that, then what". It got me thinkin
by robrtsql 6y ago
> Ever since I wrote about the whole Python/Gunicorn/Gevent mess a couple of months back, people have been asking me "if not that, then what". It got me thinking about alternatives, and finally I just started writing code.
I actually want to know: then what? As a web developer who usually reaches for Django or Flask with Gunicorn because I just don't know any better, is there a better stack that doesn't face these problems? Or is this a 'call to action' for somebody to build a better web server that follows this advice?
- EdwardDiego 6y ago> is there a better stack Apparently, it's C, or ...assembly? According to the comment above yours. Because developer time is apparently cheaper than CPU cycles. Weird.
- kenhwang 6y agoEvery time I read one her posts, I think, wow she must either work for literally dirt cheap or her code is expected to run on several thousand machines. Most projects just don't reach the scale or steadystate where developer time is cheaper than machine time. It's fun trying to squeeze the last drop of blood from stone, but it rarely makes economical sense.
- disgruntledphd2 6y agoTo be fair, I believe she spent the guts of a decade at Google and Facebook as a Production Engineer, so this isn't really that surprising.
- kuschku 6y agoAs we've seen in the cloud costs thread, going from python on AWS to Rust on dedicated hardware can push your bills from 30'000$/month down to 300$/month, which more than pays for the dev salaries (especially if you're not paying the excessive and unnecessary salaries of the bay area)
- EdwardDiego 6y agoHow many hours would you expect that rewrite to take when done by Python developers learning Rust as they do it? And what's the opportunity cost of the new features they can't create because they're rewriting existing apps? If you're arguing that Python has more runtime overhead than Rust, I don't disagree. But there's a reason people invented higher level languages than C. Rust is a far nicer systems language than C, but is it faster to develop in than Python or Kotlin? It really depends.
- ncmncm 6y agoIt is not clear that Rust can be as fast to develop in as Python or Kotlin, for the typical run of coders--people using Rust now are mostly well above average--but it is abundantly clear that, supported by good libraries, modern C++ can. Faster would be a tall order, but is not necessary. Put in the same effort, and get 10x-1000x faster code or lower resource needs. Why not?
- kuschku 6y agoThe reason I’m mentioning Rust is because you can still build your fun part of your application in python, and easily use the FFI to build any performance-critical part in Rust, C or C++. That said, with Rust or C++ you can – depending on the situation – be clearly as effective, or even more effective than with Python, and you gain an enormous performance benefit (which in turn saves you money, which in turn means you can hire even more developers)
- rb12345 6y agoI think the argument of the article is to pick the right language in the beginning so you save both developer time and runtime and don't have to rewrite in a better language later. For example, Python is a lot slower than threaded C, but quicker in terms of developer time and is memory-safe. If you pick one of the newer JVM languages though, you can get far closer to C than Python in performance once the JVM is running and still keep most of the expressiveness.
- pjmlp 6y agoAny language with AOT/JIT tooling will do.
- WilliamEdward 6y agoI don't know why rachel doesn't ever post source code or simply say what architecture she's using. I'm left to assume it's just plain c++. I'll just stick to python thanks.
- radiator 6y agoPosting the source code runs the risk of having something to defend oneself, instead of just having targets to criticize.
- dclusin 6y agoIf you're shy about managing your own memory and want to stay in a higher level language you could use the Quarkus framework or Micronaut which are Java on the JVM. Kotlin is a super-set of the java language and also adds a lot more syntactic sugar. I don't have experience w/ kotlin, YMMV. The introduction of Lambdas and the choice of modern post-EE java frameworks really takes a lot of the grind out of programming in Java. With the upcoming data classes it's going to get even better.
- flukus 6y agoI've gone down this rabbit hole recently, I was using apache because it come with a lot of nice to haves beside http handling, like authorization, session and cookie modules, but I wanted to see if c and cgi were viable for modern web development and the results were fantastic. Response times of 1ms while hitting an sqlite database every. I didn't go much further with the performance testing but it could easily handle more than most of the enterprise crap I build ever needs. C and CGI are a great simple combo. When you get down to it 99% of web development is shuffling data from sql to html and vice versa. It's so stupidly simple that the main code doesn't even hit the rough edges of c, there are almost no allocations for isntance so no memory management to worry about, everything that could possible leak memory or cause security issues is in a handful of utility functions. No MVC, no DTO's, no view models, no service layers, no templating, no client side javascript, just reading from and sql connection and printf'ing html to stdout. Without all the useless complications I ended up with far less code than the typical equivalent in a high level language with a framework. I'm now fairly convinced that most of the projects I've worked on would have been better off this way.
- bluedino 6y agoHave you hit a wall in performance yet?
- pjmlp 6y agoYes any managed language that has support out of the box for AOT or JIT compilers. Go, any JVM language, any .NET language, OCaml, Haskel, D, JavaScript/TypeScript As alternative you can try to use PyPy instead of CPython.
- luhn 6y agoAs a fellow Python user, honestly I think you're fine. Rachel's issue with gunicorn stems from the gevent stuff, which you probably don't need and I would avoid unless you do. I'm a bit mystified by Rachel's use case—A green thread hogging the process for so long that another request times out on the client? That means that requests are doing large amounts of processing and latency requirements are super tight, which sounds like a very specialized use case.