80 points · by emersonrsantos · 12y ago · 74 comments
My first job was an ISP I co-founded. In retrospect, the biggest mistake we did was over-investing in hardware, by buying two 120MHz Pentium servers when we could have gotten away with 486's and a leased Cisco access server or two.
But those two 120MHz Pentium servers with 128MB a piece, between them served up dozens of corporate websites, handled 32 dialup connections (we had a horrific setup with Cyclades serial port multipliers wired up onto a large wooden board with US Robotics Sportster modems wall mounted - the Sportster were cheap consumer grade modems prone to overheating, so stacking them in any way was generally a bad idea), ran a NNTP server with 30,000 USENET groups, mail for all our customers, and shell access.
We got 5-6 25Mhz or 33MHz 486's with 16MB RAM to use as X servers, and ran all the clients (Emacs, Netscape and a bunch of terminals was a typical session) on the two Pentiums.
I'd point out that it appears even a high volume site like HN hasn't knocked this ancient system offline.
It drives me nuts when I read about figuring out how to handle some couple hundred requests a second on racks full of modern hardware with Gigabytes of RAM. Any clearance bin laptop you can buy at Costco should be able to handle thousands to tens-of-thousands of requests per second. We're clearly doing something wrong these days.
There are a few problems: People don't know or care about profiling the basic stuff like context switches and data copies; people don't have a baseline idea of what should be possible; abstractions upon abstractions upon abstractions even when it complicates the code.
One of my biggest pet peeves in that respect is that people tend to not even know how many objects they create in many dynamic languages. Many people don't even know of any simple ways of finding out.
My most successful application speedup (EDIT: measured in speedup per hour expended - plenty of examples of much greater speedups, but they are rarely as quick) was spending an afternoon eliminating string copies in a late 90's CMS written in C++, and cutting page generation time by 30% in a system that was already heavily optimized (it provided a statically typed C++ like scripting language that was bytecode compiled at a time when most competing solutions were using horribly inefficient interpreters, and were often themselves written in slow intepreted languages).
My second biggest pet peeve is when people think system calls are cheap because they look like function calls. Sometimes you can increase throughput by an order of magnitude just by eliminating small read()'s (non-blocking filling of userspace buffer instead, and "read" from that). When I see slow throughput, the first thing I do is break out "strace" to look for unnecessary system calls...
But these problems are often a direct result of abstractions that means huge numbers of developers don't know or understand the cost of a lot of the functionality they depend on any more, and can get away with that "too often" because they work on hardware that is so fast it is extremely forgiving (e.g. my new "weird unknown Chinese brand" 8-core phone does about 10 times as many instructions per second as my ISPs total computing capacity in 1995, and it's nowhere near the peak performance of todays flagship phones), ignoring the fact that at "web scale", things are not as forgiving any more: server costs quickly start adding up.
But of course, most of us most of the time work on stuff that needs to handle little enough traffic that paying an extra $20k for hardware is cheaper than spending the developer time to optimize this stuff. Ironically this makes the optimization more expensive: Fewer developers ever get to obtain the experience to optimize this stuff at scale.
One of my biggest speedup success stories was an internal inventory reporting tool for a large-ish online retailer. The code was written in Perl, with huge amounts of data aggregation happening in memory and using loads of Perl hashes pointing to other Perl hashes point to others (and turtles all the way down). On small subsets of the data, it would run for 4 or 5 hours then spit out some graphs -- this was acceptable performance for daily reports. But as the site grew, it started taking 8 hours, then 10 hours and then finally crashing when the system simply ran out of memory.
So I did a simple conversion, all the hashes pointing to hashes etc. into arrays pointing to arrays. Pretty simple in the code, only a few lines of code here and there and a couple functions to map hash keys into array indexes.
The next day the entire inventory system did a run (with this one change) and finished in 10 minutes and AFAIK they still use that same system even though the site and user activity has grown a hundredfold.
The developer (self-taught) of the original code asked why this worked. I walked him through the big-O complexity of arrays vs. hashes, and more importantly the amount of stuff the hash type was dragging around through memory. There used to be a fantastic site with visualizations of all the perl datatypes and we sat down and started counting bytes until he understood the difference.
On a recent project my social website served thousands of concurrent requests on a notebook class hardware with a single CPU. It uses nginx and HHVM (Facebook's PHP JIT VM).
And @vidarth is right that people usually don't know how many objects they create. But if you tend to care about speed you better should be careful. The same goes for database access, raw optimised SQL with good indexes fly.
One interesting thing that I remember was trying to build a drive array back then. Trying to figure out how many IDE drives I could stuff into a 4U case to use as what we call NAS now a days.....
I did this from my house and had to upgrade to 200amp electrical service and have dedicated circuits run to my house. In order to do this the phone company had to dig up part of the road and it took them a week.. Not convenient for all that traffic down my street.
We had stupidly not thought the phone situation through, so we got offices first and investigated the phone line availability second. Luckily this was before de-regulation so the incumbent telco was legally obliged to provide service no matter what at a fixed price per line.
Unluckily we'd gotten offices in the embassy area in Oslo. Unlucky because due to the embassies, this area was one of the first in Norway to get upgraded to an automated exchange, and said exchange had last seen a major upgrade in the 1930's or thereabout (given that this was before commonplace internet access spurred a flurry of exchange upgrades), and was near capacity - until we arrived this was not seen as a problem, as the area was fully built up and there was seemingly no reason to expect any big increase in number of lines that couldn't be accomplished just fine mainly by line splitting (multiplexing two lines onto one copper connection to the exchange) that worked fine for voice calls, but not so well for modems...
Their solution turned out to be to run a massive cable largely hanging in the trees along a major road from the nearest newer exchange with decent capacity a few hundred meters away, through a hole cut in one of our windows, to a multiplexer cabinet they installed in our office.
They did tell us they were going to get it sorted out "properly" but by the time we moved to new offices they still hadn't been able to.
At least they did it quickly.
I was primarily an Amiga user still at that time - happily using an Amiga 3000 quite similar in hw specs to the Mac in the linked article as my primary desktop.
But did those have Turbo buttons? If so then you were clearly cheating.
I was actually going to add in a quip about the 486 "DX" with the math coprocessor (vs the SX which didn't have it) being cheating too initially.
Biggest lesson apart from being careful about large capital investments: If you think you can do things _far_ cheaper than an incumbent in an underdeveloped market, chances are they too can do things far cheaper, but have so far opted not to; forcing them into a price war without large backing is not a good idea.
Then we continued for a few more years doing consulting and business hosting as well as handling the backend support for IDG's Norwegian ISP, before the lawyer of our original investor hooked us up with much better paying jobs for the Norwegian office of a California based startup.
It was an interesting experience. Learned a lot. Didn't make a lot of money. But it defined my career - 6 out of my 8 subsequent jobs have a "lineage" going back to that company.
For comparison, here is a static site served by a machine with a 4MHz custom CPU: http://www.magic-1.org/ (more details at http://www.homebrewcpu.com/ )
Later, when I got my first DSL line, I had a different cast off IIci running netbsd doing NAT for my little network. That would have been 1997 or so, 640k symmetric, I think the IIci had 24 megs of memory or so. Old and slow at the time, but less powerful than this one.
A Mac IIci is ridiculously powerful in comparison.
http://en.wikipedia.org/wiki/TRS-80#Model_16.2C_Model_16B.2C...
A few years later, we had a lab running Apple A/UX on either the Mac II or Mac IIx. They were barely usable as small XTerminals at 640×480 8-bit color.
Of course, with two dozen terminals active, things does change a bit...
My first Linux machine was a IIsi, the little-brother to the IIci. But I had to put NetBSD on it because the Linux keyboard driver was broken.
And some people have run web servers on C64's too.
Contiki OS runs on C64 and provides a full TCP/IP stack for the C64 as well as a simple browser: http://www.contiki-os.org/ (This site will apparently create a customized image: http://contiki.cbm8bit.com/)
UPDATE: And it appears to have gone down. Foot in mouth!
I ran my first webserver on a Mac IIci at work, circa '94. We didn't have a firewall and were right on the internet. I soon was able to apple? script up a page with a live QuickCam image, text-box, cgi-bin, and the speech synth and let my friends have at it!
I received nothing but innuendo and sheep noises, but it was a blast. This was a year or so before I started administering the definitive Quake server on the corporate network, and dare I say... internet. Up to twenty players at a time, some on dialup.
Ah the good ol' days, hehe. ;)