3 ms·
The last two apps I have inherited have been in Python (Flask and Django). If they were slow, its because they were poorly written (one page makes over 1000 dat
by collyw 11y ago
The last two apps I have inherited have been in Python (Flask and Django). If they were slow, its because they were poorly written (one page makes over 1000 database calls - it could be done in less than ten). Sort all that crap out before worrying about the language.
- roflc0ptic 11y agoIn a talk once I heard web applications described as "database skins." Maybe it's hyperbole, but the general point seems sound - most web apps are CRUD, and the slow point in most applications is IO. I suspect not doing dumb IO is 9 times out of 10 the solution to performance problems. That said, working against oracle databases with Django is slow as all get out. Something about the driver requires numbers to be converted from number to string back to number, while calculating whether it's an integer/decimal/whatever. Simple queries returning 1000 rows could take ten seconds. I spent several days running that down. The analysts at my shop blamed django, which was pretty unfortunate.
- combatentropy 11y ago> I heard web applications described as "database skins." Not a bad description. > the slow point in most applications is IO The slowest part of web apps in my decade of experience is the database, yes, if that's what you mean by IO. Reading and writing files, also IO, is very fast though. A database can be very fast too (I've mostly used Postgres). Or it can be dog slow. It's just like how some programmers are 100 times better than other programmers. One SQL query is 100 times faster than another, and both get the same result. And it's not usually something simple like adding a column index. Usually it's a matter of a sub-select or some other squirrelly way of combining tables or aggregating a result. I wish more programmers learned SQL --- I mean really learned it through and through --- than concentrated on the latest fads.
- iofj 11y ago> I wish more programmers learned SQL --- I mean really learned it through and through --- than concentrated on the latest fads. And miss out on all the coffee breaks afforded by programmers just looping over entire databases in a horribly inefficient ORM ? Because all this condition abstraction in the ORM is really hard to use ... Don't worry though : they're optimizing it. I hear they're upgrading to run the loop in 100 threads instead of just one. Surely that will accelerate things a lot ! And if that doesn't work, we always have memcache, don't we ? Also we can now use cloud databases to spread the load, surely that'll help (I'm looking forward for the first double-digit page refresh, measured in dollars) (Having worked years for hosting providers where 20-30% of my job was making PHP/Python/Ruby/sometimes even Java applications run faster, and achieving 50x improvements on a regular basis, this had to get off my chest. And yes I've seen people implement mail address lookups by iterating over the ORM-provided collection ... and then show 50 mail addresses, wondering why the page load time was bordering on 3 digits when measured in minutes. Not even just once)
- hueving 11y agoI can't emphasize this enough. I'm always blown away by how quickly engineers will chalk a slow application up to the language it's written without even doing a minimal amount of profiling. In almost every case it has been severely limited by waiting on a massive number of backend calls, DB reads, system calls, etc and became orders of magnitude faster after fixing those silly mistakes. profile profile profile before you waste a ton of engineering effort on a rewrite that may buy you absolutely nothing.
- stcredzero 11y agoI'm always blown away by how quickly engineers will chalk a slow application up to the language it's written without even doing a minimal amount of profiling. The more things change, the more they stay the same!
- pbowyer 11y agoI now install AppNeta TraceView [0] whenever I launch a site. The free plan is fine for initial profiling and it's useful to see what matters under a production load. And the paid plan has proved itself. NewRelic is similar, but I find the TraceView interface much much better. 0: https://www.appneta.com/products/traceview/ https://www.appneta.com/products/traceview/
- bbody 11y agoMaybe part of these frameworks (Rails, Flask, etc.) reputation comes from newbies doing a lot of database calls because the framework makes it easy for them to do it. Edit: More clarity.
- collyw 11y agoDjango is probably pretty bad for this. The ORM is easy to use for easy stuff, but trying to write efficient queries with it takes a fir bit of practice.