Ask Slashdot: What Are Some Bad Programming Ideas That Work? (infoworld.com) 674
snydeq writes: Cheaper, faster, better side effects -- sometimes a bad idea in programming is better than just good enough, writes InfoWorld's Peter Wayner: "Some ideas, schemes, or architectures may truly stink, but they may also be the best choice for your project. They may be cheaper or faster, or maybe it's too hard to do things the right way. In other words, sometimes bad is simply good enough. There are also occasions when a bad idea comes with a silver lining. It may not be the best approach, but it has such good side-effects that it's the way to go. If we're stuck going down a suboptimal path to programming hell, we might as well make the most of whatever gems may be buried there." What bad programming ideas have you found useful enough to make work in your projects? Don't be shy or ashamed, we all want to hear your responses!
Denormalize (Score:5, Insightful)
I won't even call it a "bad programming idea". I've seen more problems from over normalizing a database than from under normalizing.
Maybe the bad idea is trying for fourth normal.
Re:Denormalize (Score:5, Insightful)
CNF2 is good. CNF3 is sometimes better. CNF4 is usually worse.
Re:Denormalize (Score:5, Insightful)
If it is stupid and it works, it is not stupid.
I learned the above in the military, and I have seen no reason to unlearn it in 32 years working as an IT professional... Yeah, I'm no longer a programmer, but I still reach for my favorite hammer when I see a nail. Two years ago, I embedded Assembly Code into something that operated on Terabytes of transaction data. It wasn't stupid.
Re: (Score:3)
If it is stupid and it works, it is not stupid.
I learned the above in the military, and I have seen no reason to unlearn it in 32 years working as an IT professional... Yeah, I'm no longer a programmer, but I still reach for my favorite hammer when I see a nail. Two years ago, I embedded Assembly Code into something that operated on Terabytes of transaction data. It wasn't stupid.
Define "work". I've seen reports that prints the correct numbers but that are built (I shit you not) with cartesian joints executed in loops, over and over, per row.
A more extreme example (I'm not making this shit up) - a reports server that makes a web service call to a "reports composer" service, one call per page, and for each page, the "reports composer" service makes multiple database queries per row (like not one of the a-holes who created this knew how to make SELECT SUM(somefield) FROM table GROUP
Re:Denormalize (Score:5, Insightful)
CNF2 is good. CNF3 is sometimes better. CNF4 is usually worse.
Sorta. First you analyze your model to be 3NF or 4NF. Then you denormalize in a controlled way. Logic before optimization.
Accidental 2NF usually means the problem wasn't well analyzed. And that most likely there will be problems ahead caused by bad abstraction.
Re: (Score:3)
Then you denormalize in a controlled way.
That sounds very much like something that optimizing compilers are for. Perhaps this means that the toolchains and/or abstraction levels are deficient?
Re:Denormalize (Score:5, Insightful)
Views are extremely helpful in such cases (Score:5, Insightful)
Views allow you to operate on the database as if it were denormalized, without losing the consistency guarantees and other benefits of a properly normalized database.
It's the same concept as STORING datetimes as a number internally, a consistent, monotically increasing number, while DISPLAYING them as strings like "November 6, 2016 1:30 AM". Storing "November 6, 2016 1:30 AM" is crap for any kind of calculation, especially because that string represents two different times an hour apart - there's no way to know whether that comes before or after "November 6, 2016 1:20 AM".
Similarly, views are virtual tables which provide whatever you'd like the user to see, without breaking the underlying data structure.
Re: (Score:3)
I have outsourcers who do that for me!
pop (Score:5, Funny)
using assembly language to code a web page because the boss wanted it to be fast
Re: (Score:3, Funny)
using assembly language to code a web page because the boss wanted it to be fast
The bad idea was using JavaScript/PHP/whatever in the first place.
Languages designed by clowns.
The moment they should have given up was when they realized they needed to add an extra '===' operator because they messed up the '==' operator so badly.
(and all the rest of the bad ideas they had around the same time they were implementing '==')
Re: (Score:3)
I personal worked on a rewrite of a hard real time implementation that was rewritten from C++ to java using a real time JVM, and the java version performed better in every way imaginable..
this isn't 1996..
Goto (Score:5, Insightful)
Re: (Score:3, Insightful)
I also used to do this all the time in C. Code looks a lot cleaner this way.
Re:Goto (Score:5, Insightful)
I've seen code that avoids this, or avoids multiple returns from a function, and the result was very difficult to understand. Either lots of misc state variables, or extreme indentation, etc.
Re: (Score:3)
Get a better IDE. They scroll right and left just fine.
You might also consider breaking your functions into smaller chunks.
Re: (Score:3)
8 levels deep normally means function too big (Score:3)
Indeed, if code is nested 8 levels deep, four or more of those levels should probably be separate functions. The first function might be: .= build_sql(line)
while (line = readline) {
if (notcomment) {
sql
}
}
return sql
The levels of indentation related to building the sql are off in another function, called build_sql().
Human working memory can hold about 8 items at a time, in this case 8 lines of co
Re: (Score:3)
Extreme meaning nested 8 deep, so that the inner loop is off the edge of the window, and if you resize or scroll it then it's still to confusing to read.
You could try using an editor that lets you set TAB to 2 characters instead of 8.
Re:Goto (Score:5, Interesting)
Sure, C gotos are the cleanest solution in a few specific cases and sometimes I get frustrated in higher level languages that lack it.
However I still demonise gotos when teaching coding because it should be use carefully and sparingly. New programmers often see it as a versatile stick that can solve all their problems, and while it can make the code "work" we moved on from spaghetti code for a reason.
My personal rule is that a goto should only ever go down the code and never into new blocks.
(except for implementing a try/catch system using longjump, every rule has an exception...)
Re: (Score:3)
My personal rule is simpler: if the transition would make sense in a flowchart of what the code is meant to do, then it makes sense in the code. If the only way to write that transition is through the use of a goto statement, then it makes sense to use a goto statement. This generally allows a bit more than your personal rule, but requires the person writing the code to be capable of creating intelligible flowcharts.
Re:Goto (Score:5, Funny)
Goto. I use that (in C) for error handling all the time, and frankly, it is about the cleanest way to do it I have seen.
One little goto [xkcd.com]. How bad can it be?
Re: (Score:3)
Once you get down to microcode everything is 'load program counter'. Doesn't mean 'load program counter' belongs in a high level language.
Re: (Score:3)
90% of "modern" software (Score:3, Insightful)
HTML (Score:5, Insightful)
While it's great for reporting, It will never be a good fit for real applications. When I say real, I mean the ones that you use to actually get work done and not browse kitten videos. Modern use of HTML/JavaScript is the worst example of shoving a square peg into a round hole that I've ever seen... and yet, with enough effort, we make it work.
Re:HTML (Score:4, Informative)
Applications? HTML was never meant for "applications". It was meant for web *pages*. Websites.
Re:HTML (Score:5, Insightful)
Yeah, I think that's the point. We've managed to take something meant for web pages and figured out how to embed fucking operating systems into it.
Re: (Score:2)
can you recommend a good source for kitten videos.
Re: (Score:2)
Re: (Score:3)
Those are kitchen videos...
Dear Square Peg (Score:4, Informative)
From Round Hole,
Please go look at some old houses and barns. Guess what, the construction is almost all "post and beam"...and guess what, they did it by hammering square pegs into round holes.
Why?
Because it is very hard to drill a square hole. And making round pegs is far more labor intensive than square ones, and wastes a ton of wood. Lasty, friction baby.....that's right. A round peg in a round hole will either slide in and out too easily and not be secure OR it will be so tight that the friction will make it nearly impossible to fit it in. So instead, they hammers a square peg into a round hole. Both the peg and the hole deformed slightly. Allowing for a tightly fitted peg to lock the post and beam together.
Sub-optimal code. (Score:4, Insightful)
Comment removed (Score:5, Insightful)
Re: (Score:3)
Unused cycles are wasted cycles!
Comment removed (Score:5, Interesting)
Re:Bad, you want bad: (Score:4, Insightful)
Yes it is, and yes we do.
Well, if you timed it, then you know.
Empty set (Score:4, Insightful)
There aren't any bad programming ideas that work.
Re:Empty set (Score:5, Interesting)
Bad Ideas (Score:5, Insightful)
Coding in Javascript, PHP and VB6.
Re: (Score:3)
Coding in Javascript, PHP and VB6.
There's nothing wrong in coding something in JS when it's appropriate. Some page effects can't be done any other way, and Ajax has allowed the creation of full-featured web apps that are the rival of many desktop apps. It's one tool of many in the box and it has its place.
PHP is full of warts but I love it. It's made me a boatload of money over the years and I've never regretted learning and using it. It makes my house payment (and more) every month. Hard for me to complain about that.
VB6...yeah, that one i
Re: (Score:2, Interesting)
> VB6
Yet, there are plenty of nice things about it, for example:
Debugger: you can skip the execution point forward/backwards. You can edit code _live_ whilst debugging, or execute custom code in the same context as what's being debugged, and you can debug that as well. Can your favorite language's debugger do this?
= operator that makes sense: how many beginners fall over the = vs == confusion? In VB6, you'll never accidentally assign a variable in an if condition.
With statement actually works well, un
Re:Bad Ideas (Score:5, Insightful)
Web Stack Sucks Rotting Eggs [Re:Bad Ideas] (Score:3)
Amen! Productivity (work-related) application programming (CRUD) using HTML/DOM/JS is a f8cking nightmare.
Part of the problem is that each browser brand/version combo can potentially render things differently such that you have to test on say 30+ combo's of browsers and devices to cover all bases, AND future versions may STILL break it after all those 30+ tests. My hair is turning Bernie Sanders shades over that cra
Re: (Score:3)
Re: (Score:3)
Not only VB6, any VB.
But you forgot Delphi these days - the company behind it is falling apart since lead developers on the compiler have dropped off.
Using !important in css (Score:5, Insightful)
There's a lot of cases where you end up doing something that is considered not "best practice" and is frowned upon, but it gets the job done, is not likely to cause headaches for future developers, and is the most efficient way to solve a problem. It's not programming, but using !important to force a style when you absolutely have to or to override a bad implementation of bootstrap is a surefire way to solve an issue.
FORTRAN 77 (Score:3)
and Matlab ....ffffffFFFFFFFFUUUUUUUU..........!
enough said.
Working 80+ hour weeks (Score:2, Insightful)
Seems terrible because you become less productive, but with the overhead of communication with a larger team, it's still much more efficient than hiring more people.
hierarchical filesystems (Score:3)
Or really file systems in general, but most of the modern ones has directories. File systems try to seem like a general purpose database abstraction, but using a filesystem to access data is really fraught with peril.
enum values (Score:4, Interesting)
I've occasionally relied on enumerations being particular values, as a shortcut. Makes me feel icky, tho.
Exceptions (Score:2)
Put the business logic in the database (Score:3)
Or rather forget about what's business logic and what's not - if it can be done in the database, do it there.
Re:Put the business logic in the database (Score:4, Interesting)
Bad programming ideas: separating "business logic" from the rest of your program. Not sure what the difference is between 'business logic' and the rest of your programs that run your business but a lot of people seem to want to separate them out.
Any database implements a turing complete language, it's generally a really bad idea to do anything there. Although to save time, I've often implemented SQL triggers and the like to do clean up that I didn't want to figure out in the program.
Re: (Score:3)
separating re-usable "business logic" from the vendor-specific language of your data repository
ftfy, make more sense now? Not everybody delivers (or stays) on the same RDBMS all the time. Not to mention how miserable it is to debug programs that live half in the middle tier and half in triggers. Or better yet, autonomous transactions in triggers - aren't those fun? You may want to look into interception frameworks.
Shying away from OOP(s) (Score:5, Insightful)
Re:Shying away from OOP(s) (Score:4, Interesting)
I came here to actually say OOP.
Its an absolutely terrible idea that tries to make software work the way we think it should, not the way we think.
It never ends well, and every time it goes to hell, people say "Oh, but if it had been done right in the first place..."
Though somehow people actually make it work, and right now superior functional patterns aren't taught, so if you implement them everyone thinks you're crazy. So for now, OOP is a terrible idea that "works", that many know is wrong, but that we still use for historical reason to make working software, for now.
Re:Shying away from OOP(s) (Score:5, Insightful)
Likewise. OOP is an interesting design pattern, but not when taken to the extreme. Far too often, people use inheritance where an "if" statement in a couple of methods and an initialization-time flag would have sufficed, and the result is invariably unholy.
I don't agree, however, that functional programming is an improvement. Functional programming is a migraine. In my experience, it usually causes things that are relatively trivial in procedural programming to turn into mounds of code. Everything that's bad about OOP is also bad about FP, just in different ways.
The goal should always be to produce less code, to the maximum extent possible, and both of these paradigms tend to do the opposite—particularly in the hands of beginners, but not exclusively so.
Comment removed (Score:5, Insightful)
Re: (Score:3)
You make a fair point, but I'd say 'simpler' is far more subjective than 'less', and less seems to be the right answer 95% of the time.
Re:Shying away from OOP(s) (Score:4, Insightful)
I actually think you're completely backwards. Most programmers think in terms of basic OOP and procedural programming. Nobody thinks in terms of functional programming- that's why no functional language has ever been a major commercial language.
Re: (Score:3)
It depends upon how people think about it. Some try to have each class be a real "thing" instead of being something more abstract, it's the way a lot of textbooks try to teach OOP. A file is a thing and so gets a class; a semaphore is a thing; a window is a thing that you can actually see so definitely it's a class. But a behavior, yuck, it's not a thing, so it starts to trip people up. But if you think of classes as an abstraction to tie data and behavior together, then you can look at it differently.
Re: (Score:3)
Its an absolutely terrible idea that tries to make software work the way we think it should, not the way we think.
It depends, I'd say. Coming from a background as a mathematician, I tend to see programming a bit like set theory (set theory has a lot to do with binary logic, in fact, so perhaps that makes sense). Set theory is a funny subject - the theory we learned in school ('naive set theory') is very intuitive and gives us some profound insights into the nature of several important concepts; but it also runs into serious problems, like the Cantor Paradox. To get around these problems, there are now several, highlly
Re: (Score:3)
An example of domain modelling would be a human resources app that models employees, managers, offices, etc. as objects. This mostly flopped
This is not an example for OO. Because the design is wrong.
Hence your conclusions are wrong.
The correct domain model is Person, Role, HierarchicPosition where every Person has a set of Roles and HierachicPositions define your company layout/hierarchy and has a set of Persons filling those positions.
But OOP works fairly well for making API's to network and system service
Re:Shying away from OOP(s) (Score:5, Informative)
I had to work under a lead who had "Design Pattern Prejudice". Every class had to be named based on the pattern it took after, and everything had to come from factory factories that worked off interfaces to abstract parents at every step, everything had to be immutable, and in any given review, he'd point to a section of code and ask what design pattern this followed. If you couldn't specify one, he'd fail the review, and if you could, he'd want you to rewrite it to use at least 2 or 3 more patterns.
Granted, he'd spend a whole week writing code, fail to complete any of his issues, and check in around 40 new classes & interfaces, but not one of them had any business logic in them at all, and then demand everyone refactor their code to use his new architecture.
We only got things done when we started ignoring him.
Re: (Score:3)
Sometimes just listening to the client is the quickest way to get things done, instead of listening to the other programmers. In other words, just find out what the code is supposed to actually do, rather than how it's supposed to do it.
Re:Shying away from OOP(s) (Score:4, Insightful)
Re:Shying away from OOP(s) (Score:5, Informative)
It could definitely be an anti-pattern if used incorrectly, but honestly, I've been programming in C++ for about twenty years, and do you know how many times I've seen co-workers abuse operator overloading? Precisely ZERO. Seriously... never seen it. Apparently, I work with people who weren't stupid to flagrantly abuse operator overloading for no good reason, even among those who didn't exactly produce the cleanest or more elegant code.
On the other hand, this is the type of code I typically work with:
Vector3 posDelta = position - lastPosition;
Or this:
Matrix m = m1 * m2;
Overloading operators is best done in an absolutely literal sense. For instance, if you're doing matrix multiplication or subtracting two positions to get a delta value, the intent and what's happening in the code is 100% clear to everyone.
I chuckle sometimes at how C programmers believe that there's some evil overloaded operator lurking behind every multiply or addition. Uh, yeah... you can also obfuscate the crap out of your C programs too (pretty sure I've heard about some sort of contest too *cough*), but you just don't do that.
Re:Shying away from OOP(s) (Score:5, Interesting)
Some of us are old enough to have gone through a generation of "overload everything" which was a disaster.
Only much later did people learned to use overloading sparsely and with good effects.
This is similar to OOP which is also overused. Heck in Java you can't even have a variable or a function living on its own. Everything must be an object (except native types, sometimes).
Re:Shying away from OOP(s) (Score:4, Insightful)
Bad programmers are bad programmers no matter what language or paradigm they use.
I think some of this arises from someone doing busy work and getting the feeling that they're making progress. Ie, create lots of classes, draw lots of lines between them, and it sort of looks like a design. Now you spend the next few months implementing the skeleton of all those classes, and then every time you go home it feels like you put in a good solid day at work, your boss looks at lines of code and you seem productive so you get a nice raise. If your fingers get sore from all that typing, then you just call a few meetings to start debating the merits of class naming, which patterns are missing that should be added, how to improve the whole process, and so on.
Re: (Score:3)
Haha, never heard that one. Far more appropriate, although I still don't get people's beef with well-factored OO code. As far as I can tell everybody just reacts to either the readability aspect (there is plenty of IDE tooling for making class/interface hierarchies easy to understand, and FFS it's not meant for linear scripting, people) or the time they got some evangelist nutjob on the team who jammed OO where it didn't need to be (not exactly the language's fault). There is a difference between a bad too
Good enough that people won't stop doing it... (Score:3, Interesting)
... despite that I keep telling them not to, but never good enough to save their business plan or their company from disregarding my wisdom.
- Agile/scrum, anything related to it, inspired by it, or even remotely like it, and the mindset of managers who advocate it.
- "continuous integration"
- "devops"
- server-side javascript
- giving every single person in the IT department the root server access
- using microsoft "solutions"
Re: (Score:3)
I agree with everything on your list except continuous integration. What makes CI a nightmare is that so many CI systems basically eat themselves from the inside out, randomly, causing everything to stop while somebody wastes half a day to debug the CI system. But when it works, CI is a godsend. It makes it easy to know exactly when things started to fail (tests, building, etc.), which makes it much easier to pin down the causes for some types of problems. (Obviously for building, this is trivial, but
Multiple Returns (Score:4, Insightful)
For a while the mantra was that you only return from a subroutine in one place, at the bottom.
I think that's been pretty much abandoned. Return when you're done; don't go through contortions to get out of nested loops or IF statements just so you can get to the return at the bottom.
Re:Multiple Returns (Score:4, Interesting)
Re: (Score:3)
What the compiler does truly doesn't matter. All those rules you are supposed to obey are only intended for correctness and clarity on source code level.
Assembly only has one kind of flow control ("jump", i.e. goto), but that certainly does not imply that you should only use goto's everywhere from now on!
Javascript (Score:2, Insightful)
Javascript, the worst possible programming idea that seems to unfortunately work.
Re:Javascript (Score:5, Insightful)
Javascript, the worst possible programming idea that seems to unfortunately work.
Son, you only say that because you've never poked the Cold Fusion bear. In earlier versions, it didn't even have subroutines.
Tcl (Score:3)
Comment removed (Score:4, Insightful)
Re:MUMPS (Score:4, Funny)
Interpretting instead of compiling (Score:3)
Magic Numbers! (Score:5, Funny)
Magic numbers save tons of time. You get to working code quickly to verify your algorithm. They nev
>Segmentation Fault
Switch(true) (Score:5, Interesting)
switch(true) {
case $a < 5:
do something;
break;
...
}
A bit messy, but a lot cleaner than a stack of if/then/else for a set of of conditions.
Javascript (Score:4, Informative)
I've heard PHP is just as bad but, as I've never written anything in PHP I'll give it the benefit of the doubt.
The latest trend is not your friend... (Score:3)
I've been dwelling the past months in my team's will to go full-fledged MVC (actually MVP) while developing for the Android SDK (for those out of topic: making apps). I see peers and myself struggling with old, large activities, running laps around to make them pass "technical debt" code reviews intending to "make them more future proof".
It would be nice and all if I could grasp the benefits, but the problem is three-fold:
a) the team is fooling themselves and the company into spending too much resources in something they can't assure adds value;
b) Android already has a very solid MVP-like pattern going on, and MVP-ing it up further is a clear case of overengineering
c) most important of all: there is no actual standard to guide the team, so it's a free for all and I see all the initial benefits down the drain just because everybody tastes a different flavour of the view/presenter combo
And I see and underlying problem which might even be more crucial: the app will likely be dropped before reaping the long-term benefits, turning the entire endeavor TOTALLY WORTHLESS. So what I'm trying to say is: you got a solid framework with great patterns put in place already, developed by a company that is on the tech top 10, and you decide to be all trendy around it? You're pretty much grinding for a promotion you definitely don't deserve, because you're making that framework worse for everybody that you manage.
Objective-C (Score:4, Interesting)
process per request (Score:3)
Terrible in terms of scalability, but generally works for small workloads. Plus it largely sidesteps developers having to understand how to write thread-safe code.
PHP (Score:5, Interesting)
I can do python flask stuff that is technically cleaner, I could even do something super hardcore like a C++ we back end but for the easy homerun, PHP it be.
Obviously I am talking about the web.
Another dirty secret is that I do most of my stuff from scratch. Nearly every framework or great IDE extra out there I ignore. The whole storyboards thing in iOS, nope, Java on Android, nope, or just about any proprietary system that tells me how I should do something is a big fat nope. I find with most huge frameworks that I can knock of an almost fully functional prototype in no time at all, but then I start fighting with the framework and can never finish, 90% done and that is it.
By working with the fundamentals and good libraries, I start slow, and finish slow, but finish I do.
Duff's Device (Score:5, Interesting)
Seriously, the first time I saw Duff's Device [wikipedia.org] I really thought it was a mistake. It's a do/while intermingled with a case statement. Look it up and be amazed.
Flat files... (Score:3)
Back in the early 90s I worked at the big cellphone company. We worked on Unix workstations, and I learned a lot of what to do and what not to do. We used an in-house built bug system built to use sccs. I managed the build shell scripts. The only way to get code into the build was to enter a CR (Change Request) and link the source files to it. Then the build would examine all the CRs for a weekly build, check out that code, ftp it to the target platform (tandem), build it. If all went well, 8 hours later you would have a successful build, which I would then write to 9 track tapes, and THEN install it on the target system testing platform.
So the bug system I mentioned used flat readable text files to store all the info. There was a gui front-end but it was kind of slow.
Out of necessity to quickly look things up, I wrote a shell script that would allow you to search and view CRs on the command line. Bad built on top of bad, but it worked pretty well. Other people on my team started using it too.
It worked so well in fact that somewhere around 2006 I was living across the country, having been at a few other companies since then. An old colleague still at my first company got in touch with me, and someone was asking about me and the tool I created. They saw my email in the header of the script, and wanted to get in touch with me to see if I would let them edit it. They were still using it! What I created for myself others found so useful that it was still chugging along doing its job on the command line. I don't know if it made me proud or sad, but it was humorous to me. I haven't heard anything from them since then, but it would be very interesting if they were still using that same process and those shell scripts I created so long ago.
Re: (Score:2)
Re: (Score:2)
That is what I came in here to say. Bubble sort, bad programming at its finest but can't be beat when you need a simple and fast way to reliably sort a small list.
Re: (Score:3)
I always see people implementing some sort of bubble sort (often badly) in higher level languages like Java, PHP and Python. I don't understand why, there is a perfectly good sort method in most if not all languages yet every idiot programmer seems to want to reinvent it.
Re: (Score:3)
I wrote a hobby-program once that needed to sort a list. A really big list - too big to fit in memory. After much thought I came up with a really neat search algorithm, a sort of modified radix sort that used only linear access and so would run with good performance from reading from a file. I doubted I could have invented a new approach to sorting, but I couldn't find anything quite the same as it.
A couple of years later I came across that algorithm - in a book that dates from the mainframe era, describing
Re: (Score:3)
I have found many of those tests to actually be useless. Such as testing that the implementation is doing what the developer thinks the implementation should be doing, rather than testing that the behavior is correct. And then never documenting what those tests were really supposed to be testing (maybe testing that OS version must by 1.2.3 because they all break in 1.2.4).
Or the useless tests that don't really exercise anything important. Such as add 100 items to a list and then pull them all off and mak
Re: (Score:3)
It was a bit loopy.
Re: (Score:3)
That's elitist bullshit. Sure, programmers vary in qualifications from horrifyingly bad to mindblowingly excellent, but don't use words like "application programmer" for our less gifted brethren and "system programmer" for the better ones; that just makes you look like an elitist prick.
Re: (Score:3)
Also works when a 23 year-old "expert" from one of the big consulting firms reports to the CIO that the servers are underutillised.
My reply was "certainly, what level of utilisation would you like?" but the grin on my face gave it away. It was then followed by a laymans explanation of utilisation vs. response times. And a decision that the consultancy wasn't in the company's best interests.
You left money on the table with that.
I don't know the context...how many other people were working alongside this guy, or how representative he was of the team (if there was one) that was there. But if he worked for the consultancy I work for, we'd have wanted to know about this. You should have raised this (along with what must have been several other curious ideas from the guy) to the account manager/account executive/throat to choke (the technical term) for your company. I'm pretty sure that the guy'
Re: Bad programming idea that works (Score:4, Informative)
Depends on the utilization patterns.
Heavy I/O utilization will give you a bad time. As a counter-point, overprovisioning RAM relative to your working set will cut back on some of the I/O--a lot, if you're not on a write-heavy workload or a database. Correct RAM provisioning has to include the working set (application memory) and page cache (which is working set represented on disk, rather than persistently loaded into memory by the application).
PU utilization at 90% during peak is fine, if your applications can handle it. A PHP or C# application that can service 5,000 requests per second only takes, on average, 1/5000th of a second to fully-service a request; if it's designed to queue and thread in some sane way, then it shouldn't stall later requests because an earlier request is waiting for something. Its ability to handle 5,000 requests per second includes all that overhead: you can't automatically scale the HW requirements to service 100 RPS and claim now it does 5,000.
An nginx server at 90% utilization typically operates just fine, because nginx (as a reverse proxy, caching proxy, or static file web server) *does* serialize sanely. It provides one worker per CPU (configurable), and passes requests to workers under the least load. Each worker serializes requests--they service one request at a time--and will basically put a waiting request on hold and immediately start servicing a different request. If a worker is waiting with no request to service, it can take a new request--even if it has 37 requests all waiting for something (I/O, a back-end proxy, an application).
Writing an application to handle parallel requests with that kind of efficiency is *hard*. It's not impossible, and some applications handle it well; others do in fact increase latency significantly with utilization.
Latency will, of course, always increase when utilization exceeds unity. Using more than 100% of all CPUs means something has to wait.