3 ms·
Algos and Code Performance: Your Code Works but Can It Handle Real Traffic?
- aaronbrethorst 1y agoRule 1 for performance optimization: measure before trying to make any changes. It’s easy to waste a lot of time and energy optimizing something that isn’t actually going to meaningfully improve your web app’s performance. Personally, I like Sentry. They have a pretty generous free tier and a great code/db tracing tool. (And yes I see that the author lists ‘measure’ as their second point. I think they’re mistaken.)
- ivanmontillam 1y agoThis article is also very easy to misinterpret. This article cannot be read by software developers that still fall into premature optimizations traps. Basically, you must be first experienced or this kind of advice will hurt your codebase.
- atomicnumber3 1y agoAnd rule 0 is: if there's nothing to measure, there's nothing to optimize. In my career, the worst "oh shit this doesn't scale" problems have been encountered in systems that were grossly over-designed - to the point that development had a noticeable "tax" due to dealing with it - and then the first time they encounter actual load (a customer writes a tight for loop on our API, or a customer decides to make 100000 of our widgets via automation, etc) it immediately shits the bed because they had no idea something would need to scale along a certain axis. And mind you, that's really no ding on the original devs. Except for 2 points: they'd been banging on about how big-brain the original architecture is, and now the unanticipated scaling axis is orthogonal to the one we had originally invested so much in scaling along and it's significantly hampered by it. It's really just best to write something simple that works and just doesn't commit any obvious sins. Then when you learn your REAL requirements, it'll be easy to adapt the code to them.
- izacus 1y agoTrue, measuring is critical. But if you fundamentally misdesigned your software, measuring won't help you (except to tell you everything is fscked). Having some fundamental skill of designing performant systems is critical on a team.
- aaronbrethorst 1y agoHow do you even know if you fundamentally misdesigned your software?
- mannyv 1y agoOptimization can't fix a bad design. You have to design it to perform; optimization speeds up hotspots in the design. But no optimization will make your app scalable or perform well under load. You can throw money at it by scaling vertically or horizontally, but that won't fix bad design (though it'll keep things going).
- 4ndrewl 1y ago> , performance should be a consideration from the start Don't obsess over this. Obsess over documenting your design decisions - why you decided one algorithm or pattern over another and why. Then _if_ after load testing you need to optimise you'll understand some of the tradeoffs you'll have to make (all decisions are tradeoffs).
- izacus 1y agoNo, please do obsses over this while designing. The amount of times I have to say "you can't fix these performance issues without rewriting majority of your software" is too damn high. I mean, I make a lot of money as performance specialist, but it's still a dumb waste when you see failing products and companies because their rockstar developers refused to spend 30 minutes thinking about how well their architecture and code performs. You can't fix everything later.
- 4ndrewl 1y agoBut most organisational failures are not down to performance - they're down to market fit. You don't have performance issues if you don't have a product that people want. :)
- izacus 1y agoI disagree (and have - sadly nonpublic - numbers to prove it). Also, it costs you VERY little to spend some brainpower to design your product to perform well. I honestly really don't understand why so many developers behave like it's physically painful to think for a bit before starting to bash out code. Noone expects you to write microoptimizations, but applying basic knowledge learned in CS classes and knowledge you can read in blogs should not be physically painful. And you can do that outright at the start, at __NO__ cost to your development velocity.
- 4ndrewl 1y agoAgree there's a basic level, and as you say just spend a little time on it but that's table stakes. My reading of "obsess over it" _is_ micro-optimisations which are a distraction if you've got no market fit
- tomjuggler 1y agoThis is a great list of all the things the tutorials fail to mention, which you have to learn through hard lessons down the line.